Skip to content

fix: support @napi-rs/canvas 1.0.12+ and require ^1.0.13 - #103

Merged
otnc merged 1 commit into
mainfrom
fix/canvas-1.0.12-compat
Oct 24, 2026
Merged

otnc merged 1 commit into
mainfrom
fix/canvas-1.0.12-compat

Conversation

@otnc

@otnc otnc commented Oct 24, 2026

Copy link
Copy Markdown
Member

Follow-up to #102, which capped @napi-rs/canvas below 1.0.12. With font family names quoted, the latest release works, so this lifts the cap.

Verification (canvas 1.0.8 vs 1.0.13)

  • Visual gallery, 142 images: 47 identical, the rest differ by 0.1% to 1.85% of pixels, from sub-pixel glyph positioning and anti-aliasing. Line breaks, font sizes and layout are unchanged.
  • Font matrix, 30 families × regular / bold / markdown bold: all 22 catalogued fonts, Google Fonts fetched by name (M PLUS 1p, BIZ UDPGothic, Zen Kaku Gothic New, Kosugi Maru, Noto Serif JP), and fonts registered with registerFromPath() / registerFromURL() under aliases such as 2nd Custom Font and O'Brien Sans. No tofu and no render failures on either version.
  • Visible change (a fix): variable fonts (Noto Sans JP, Noto Sans SC, Noto Serif JP) now honour their weight axis. Before, regular text was drawn at the thin default instance and markdown bold in Noto Sans JP was not bold.
  • Tests: 889 passed on 1.0.13. npm run visual: 145/145 ok.

Changes

  • @napi-rs/canvas: >=1.0.8 <1.0.12 → ^1.0.13, and the lockfile now resolves 1.0.13 so CI runs against it.
  • A real-canvas test reads ctx.font back after assigning fontString() output for families that need quoting. With the quoting removed, it fails on 1.0.13.
  • Updated the textStyle.ts comment that said variable fonts only expose their default instance.

The gallery in docs/visual/ is regenerated by the release workflow.

With font families now quoted, @napi-rs/canvas 1.0.13 renders the whole visual gallery and every catalogued, Google Fonts and self-registered family without tofu, with layout and line breaks unchanged. The one visible difference is a fix: variable fonts such as Noto Sans JP and Noto Sans SC now honour their weight axis, so regular text is no longer drawn at the thin default instance and markdown bold is real bold.

Require ^1.0.13 so every install renders the same way, run CI against it, and add a real-canvas test that fails if ctx.font rejects a font shorthand built by fontString().
@otnc
otnc merged commit 2b7dc16 into main Oct 24, 2026
5 checks passed
@otnc
otnc deleted the fix/canvas-1.0.12-compat branch October 24, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant