Releases: samizdatco/skia-canvas
Releases · samizdatco/skia-canvas
v3.0.8
v3.0.7
Bugfix
- Added missing TypeScript definitions for
resizableproperty (thanks to @goldenratio #265)
Misc. Improvements
- Upgraded Skia to milestone 140
- Added a bounding box hierarchy cache to further speed up canvas-to-canvas drawing via drawImage or drawCanvas (thanks to @Shiranuit #261)
Full Changelog: v3.0.6...v3.0.7
v3.0.6
v3.0.5
Misc. Improvements
- Decreased memory usage when drawing one canvas's contents onto another (via drawImage or drawCanvas).
- Reduced dependency footprint (from 294 to 22 modules when installed with
devDependenciesincluded):- replaced
nodemonwithnode --watch - replaced
jestwithnode --testfor unit tests - replaced
expresswithhonofor visual tests - dropped
lodashandfast-globusage in test suite
- replaced
Full Changelog: v3.0.4...v3.0.5
v3.0.4
Misc. Improvements
- When installing the module, any proxy server defined via
npm config set proxyor anHTTPS_PROXYenvironment variable will be used to fetch the prebuilt binary - Replaced
fetchaltogether, now using Node's built-inhttpandhttpsmodules for better backward compatibility, support for additional request parameters for loadImage(), and a further reduction in the number of npm dependencies (now down to 8)
Bugfixes
- Variable fonts can now correctly function as fallbacks (previously only the first-matched font in a stack would be converted to a usable instance)
Full Changelog: v3.0.3...v3.0.4
v3.0.3
Bugfix
- Fixed a segfault where windows on Vulkan platforms were being deallocated incorrectly upon close.
Full Changelog: v3.0.2...v3.0.3
v3.0.2
Misc. Improvements
- Only use
node-fetchon systems lacking a built-infetch - Dropped
fast-glob(reducing external dependency count to 11)
Breaking Changes
- Glob-handling has been removed from FontLibrary.use(). If you want the old behavior, try using the
fast-globorglobmodules to prepare the file-list you pass to the method.
Full Changelog: v3.0.1...v3.0.2
v3.0.1
Bugfixes
- update
node-fetchto v3: cross-fetch was stuck on v2 (which was printing a punycode deprecation warning on newer node versions) - update
winitto 0.30.12: fixes a crash-on-quit bug on macOS 26
Full Changelog: v3.0.0...v3.0.1
v3.0.0
New Features
GUI
- The
Appglobal now has aneventLoopproperty which can be set to:"native"(the default) in which case the Node event loop is suspended while the OS handles displaying GUI windows"node"where the Node event loop maintains control (allowingsetIntervalandsetTimeoutto run) and handles GUI events manually every few milliseconds (though note some of the caveats associated with the Winit feature this uses).
- Window objects now have a read-only
closedproperty and emit acloseevent when they are closed. Closed windows can later be re-opened by calling the newopen()method. - The new
borderlessattribute allows Window titlebars and borders to be hidden (thanks to @hydroperx #230)
Imagery
- The
loadImage()andloadImageData()helpers now usenode-fetchto handle web requests and can accept a fetch options object as the final argument. Imageobjects can now be created by passing a Buffer or dataURL-containing string as a constructor argument and will be immeditately drawable (no asynchronous loading required).- Added support for integrating the Sharp image processor into canvas workflows (if the
sharpnpm module has been installed):- The new Canvas.toSharp() & ImageData.toSharp() convenience methods convert their contents to a Sharp bitmap object
loadImage()&loadImageData()can now be called with a Sharp object as their sole argument- The
srcproperty on a new Image object can be set to a Sharp object and it will begin asynchronously loading
- Added new options to
createTexture()for setting the line cap style and selecting whether vector patterns should be clipped or outlined
Rendering
- Significant speed-ups for deeply layered drawing in which the canvas isn't cleared or reset (potentially resulting in numerous vector objects being re-drawn despite being hidden by shapes drawn on top):
- The bitmap generated by getImageData()/toBuffer()/toFile() is now cached. When called repeatedly, only newly added drawing commands will need to be rasterized (and will be layered atop the bitmap saved in the prior call).
- Window contents are now cached between screen refreshes, improving performance during resizing and in cases where the canvas is drawn to in multiple passes and not cleared with every frame
- Calling clearRect() or fillRect() with an area that covers the canvas now erases all the vector shapes below
- The toFile(), toBuffer(), and toDataURL() methods now accept an optional
downsampleflag (for jpegs only), which enables 4:2:0 chroma-subsampling. By default, no subsampling (a.k.a. 4:4:4) will be performed - The getImageData() method now accepts additional rendering arguments (
density,matte, andmsaa) which behave the same as their equivalents in the toFile() method.
Typography
- Text lightness can now be fine-tuned through a pair of optional arguments that can be passed to the Canvas or Window constructors:
textContrast— a number in the range 0.0–1.0 controlling the amount of additional weight to add (defaults to0.0)textGamma— a number in the range 0.0–4.0 controlling how glyph edges are blended with the background (defaults to1.4)
- The
textAlignattribute can now be set to"justify" measureText()has been rewritten to calculate metrics based not just on the font specified infontbut also any fallback fonts that were used for character glyphs not present in the ‘main’ font. The line-by-line measurements now include arunsarray with bounds and metrics for each single-font range of characters on the line.
Supported Platforms
- Added precompiled binaries for Arm-based Windows systems
- Now providing pre-built ‘layer’ archives for use with AWS Lambda (for Node v20 and above)
- Linux builds now include a statically linked version of fontconfig, as a result:
libfontconfigpackages no longer need to be installed on the host system usingapt,apk,yum,dnf, etc.- it now runs on ‘serverless’ platforms like Vercel without modification (sadly Cloudflare doesn't support native modules at all though)
Breaking Changes
- Renamed export functions and options to be more consistent with similar browser APIs and other Node modules:
saveAs()andsaveAsSync()are now calledtoFile()andtoFileSync()toDataURL()now behaves the same as its browser equivalent: it is synchronous and its only configuration option is a numericalqualitysettingtoDataURLSync()has been removedtoURL()andtoURLSync()produce data URLs and support the same enhanced export options astoBuffer
- When exporting to an SVG, text is now converted to paths only if the
outlineoption is set totrue
Misc. Improvements
App.launch()now returns a Promise that resolves when the final window is closed, allowing you to schedule code to run before the process would otherwise exit (see also the newidleevent which fires under the same circumstances).inputevent objects now contain aninputTypeproperty to distinguish between insertion, deletion, and IME composition- Mouse events are no longer coalesced down to a single instance per frame (most relevant for
mousemoveevents) - Mouse events now include a standard
buttonsattribute - DPI metadata is now included in webp files (reflecting the
densityoption passed to toFile() or toBuffer()) - Argument validation now emulates browser behavior much more closely—including converting what were previously TypeErrors in certain cases into silent failures. To reënable these errors, set the
SKIA_CANVAS_STRICTenvironment variable to1ortrue. - Replaced
node-pre-gypwith a custom installation script andglobwithfast-glob, cutting the number ofnode_modulesdirectories installed from 83 to 29. - loadImage(), loadImageData(), and Image.src can now accept URL objects (using http(s), file, or data protocols). Likewise, toFile() now accepts
file:URLs (allowing relative paths to be constructed withimport.meta.url) - The Canvas constructor's options argument can now contain a
gpuproperty which can be set tofalsein order to use CPU-based rendering
Bugfixes
- Setting a window's
cursorproperty to "none" now hides the cursor - Spurious
movedwindow events are no longer emitted during resizes resizeevents now update the window object’s width & height properties in addition to providing the new size in the event objectroundRect()now reflects context's current transform state and accepts plain{x, y}objects for corner-...
v2.0.2
New Features
- Added
fontHintingattribute (off by default to better match font weights in browser rendering). Setting it totruemay result in crisper edges but adds some weight to the font.
Bugfixes
- Text spacing
- Setting
letterSpacingno longer indents text at beginning of line letterSpacingnow properly handles negative values
- Setting
Misc. Improvements
- Improved accuracy of
measureText()- Now uses font metrics' default leading when the line-height is left unspecified in the
ctx.fontstring (NB: this is likely to cause vertical shifts for non-alphabeticbaselines) - Updated baseline offset calculations for
middle&hangingto better match browsers - The
actualBoundingBox*&lines[].x/y/width/heightrectangles returned by measureText() are now just the glyph-occupied area, not the whole line-height of the textblock - Fixed the sign on
actualBoundingBoxLeft(positive values now mean left of the origin) lines[].baselinenow corresponds to the selectedctx.textBaseline, previously it was always the alphabetic baseline
- Now uses font metrics' default leading when the line-height is left unspecified in the
- TypeScript definitions no longer include the entire DOM library (which had been pulling in tons of non-Canvas-related object types that this library doesn't emulate)