← the effing blog

Effing 0.49.0: shape up

Canvas now lays its text out with the Blink-style shaper from upstream @napi-rs/canvas 1.1.1, and the bundled FFmpeg moves to 9.1 for its security fixes.

Effing 0.49.0 is out, with two changes. @effing/canvas now lays out its text with the Blink-style shaper that upstream @napi-rs/canvas 1.1.1 brought in, instead of SkParagraph, so fonts resolve and fall back the way they do in Chrome. And the bundled FFmpeg moves from 9.0.2 to 9.1, which fixes security issues that no 9.0.x release fixes yet.

Text on the shaper

Upstream 1.1.1 replaced the code behind fillText, strokeText and measureText with a HarfBuzz shaper modeled on the one in Blink, Chrome’s rendering engine. It segments text into runs and falls back between fonts the way Chrome does. On its own, that wouldn’t reach the text renderReactElement() draws, because @effing/canvas lays out its text with the Paragraph class from @effing/skia, our fork of @napi-rs/canvas, and Paragraph was built on SkParagraph. So we gave Paragraph a second engine on the same shaper, with the same line model, and @effing/canvas now uses it via @effing/skia 1.1.1-effing.1.

Line boxes, line breaking, justification and soft hyphens work as before, and the canvas tests pass. Of our pixel comparisons against Chrome, only one fixture changed, and it moved closer: a Hebrew line truncated with an ellipsis is now cut at the same edge as in Chrome (a small difference remains, because Chrome’s narrower ellipsis fits one more character).

It’s faster for video, too. The shaper caches the lines it has shaped, so laying out text it has seen before (the next frame of a video, or Yoga measuring a node again) is about 1.5 to 2 times faster than before. Short new text takes about as long as it used to. A long paragraph seen for the first time can take up to about 50% longer.

What you might notice:

  • Fonts resolve as in Chrome. A family that isn’t registered, whether a generic one (sans-serif, serif, monospace) or a name like "Helvetica", now resolves to the matching installed family, where SkParagraph used one default font for all of them. A family with no installed match, such as a misspelled name, falls back to the default serif font, as Chrome does, where SkParagraph used the default sans-serif one. Family names are matched case-insensitively. If two equally good fonts are registered under the same family name, the one registered last is now used, where SkParagraph used the first.
  • Missing characters fall back to installed fonts. A character that none of your fonts have is drawn by an installed font that has it, as in a browser, instead of as a missing-glyph box. That also means the result now depends on the machine’s fonts. To get the same output everywhere, register a font that covers the character. This matters most in slim containers, which often have few or no fonts installed.
  • Text is shaped by bidi run, with Chrome’s script segmentation and letter spacing. Letter spacing now also widens the spaces between words in a cursive script like Arabic, as Chrome does.
  • Ellipsis truncation cuts at the line’s end edge, as in Chrome, unless the line is justified. When a left-to-right line ends in right-to-left text, it’s the start of that text that gets cut, not its end.

FFmpeg 9.1

@effing/ffmpeg now installs FFmpeg 9.1, built as before by effing-ffmpeg-builds with mbedTLS 3.6.8. We’d usually wait for a patch release rather than jump to a new FFmpeg minor, but 9.1 fixes CVEs that affect 9.0.2, and upstream hasn’t released a 9.0.3 yet. One of them is CVE-2026-107678, a stack exhaustion caused by freeing MP4 pssh boxes recursively.

9.1 is a feature release, so it brings other changes too. One is that it removes the asf_o demuxer.

To check for regressions, we rendered every video from the FFS integration tests with both 9.0.2 and 9.1 and compared them stream by stream. All 96 tests pass, and 54 of the 61 videos come out identical. The other seven differ only slightly, for two reasons:

  • swscale honors chroma siting. When it scales, swscale now takes the chroma sample location (left siting) into account, so color comes out very slightly different on scaled video.
  • The AAC encoder was retuned, so encoded audio isn’t byte for byte the same as before.

Planned for 0.50

Upstream @napi-rs/canvas has since released 1.2.1. It’s on Skia m158 and registers fonts as CSS @font-face faces with weight and style descriptors. The port to @effing/skia is under way, and we plan to move @effing/canvas onto it in 0.50, registering each font with its weight and style.

Upgrading

Bump your @effing/* packages to 0.49.0. Things to check:

  • Register a font for every family your text uses, and for any characters outside those fonts that you need to look the same everywhere. Text in an unregistered family, or rendered with fonts: [], can now get a different font and line height than before.
  • If a family name in your styles matches neither a registered font nor an installed one (a misspelled name, say), text in it now falls back to serif, not sans-serif.
  • If you register several fonts under the same family name with the same weight and style, the last one now wins, not the first.
  • If you compare renders pixel for pixel, expect text in fallback fonts, Arabic with letter spacing, and right-to-left text truncated with an ellipsis to change. The output of FFmpeg’s scaling and AAC encoding can differ slightly too.
  • With checksum verification on (the default), @effing/ffmpeg replaces the 9.0.2 binary on its next install.
  • If you draw on a canvas from createCanvas() directly, upstream 1.1.1 lays out fillText, strokeText and measureText with the same shaper, adds fontFeatureSettings, fontVariantLigatures and other text properties, and rounds font sizes down to the nearest 1/100px.

The full per-package changelogs are in the release PR.