Skip to content

v1.2.1

Latest

Choose a tag to compare

@github-actions github-actions released this 25 Nov 07:53
v1.2.1
040880c

Highlights

node-canvas registerFont() descriptors and cleanup (#1473)

registerFont(path, { family, weight, style }) now passes weight and style as @font-face descriptors. Families registered one face per call now select the requested regular, bold, italic, or bold italic face correctly, fixing the v1.2.0 regression reported in #1472.

const { registerFont } = require('@napi-rs/canvas/node-canvas')

registerFont('./fonts/Lato-Regular.ttf', { family: 'MyLato', weight: 400 })
registerFont('./fonts/Lato-Bold.ttf', { family: 'MyLato', weight: 700 })
  • Descriptors follow the @font-face grammar, including numeric weights, calc(700), and 'oblique 10deg'. Omitted or invalid fields are auto.
  • An explicit weight, including 'normal', pins a variable font to that weight. Use a range such as '100 900' to preserve its variation axis.
  • Faces declared bold or italic follow their descriptor without adding synthetic bold or italic when the underlying file lacks that style.
  • deregisterAllFonts() removes only the registerFont() registrations owned by the current thread. Registrations made through GlobalFonts and loadFontsFromDir() remain untouched. Worker registrations survive worker exit, matching node-canvas; worker pools should call deregisterAllFonts() before each worker exits.

Behavior change: a non-empty family is now the face’s only name, matching Chrome’s new FontFace(family, ...). Pass family: '' or the embedded family name to register the face under its embedded name.

Chrome-compatible fontVariationSettings and variable-font fixes (#1470)

The non-standard, experimental ctx.fontVariationSettings property now follows Chrome’s CSS font-variation-settings parsing, serialization, and WebIDL coercion:

  • Supports CSS math functions, comments, escaped quotes and backslashes, tags containing commas, duplicate tags with last-value-wins behavior, and ascending tag-order serialization.
  • Invalid values are ignored without corrupting the current font state. Non-string values use WebIDL ToString; Symbol values throw a TypeError.
  • Variable fonts avoid incorrect synthetic bold or italic when fontVariationSettings overrides their wght or slnt axes.
  • .ttc faces preserve their collection index across font cloning and variation paths, including Fontations and DirectWrite.

Skia chrome/m158 (#1469)

Upgrades Skia from chrome/m157 (b94213a11b) to chrome/m158 (37e919d866). The Skia-tied Fontations dependencies are synchronized to font-types 0.12.6, read-fonts 0.45.0, and skrifa 0.48.0. This also updates the Windows Skia build toolchain.

What's Changed

Full Changelog: v1.2.0...v1.2.1