Bug: in Firefox, layoutNextLine breaks at a soft hyphen Firefox doesn't break at (270.27px to Pretext, 276.08px in Firefox, at 271)
Versions: @chenglou/pretext 1.0.0 from npm. Firefox 160.0 on macOS (the installed release, driven by Playwright over WebDriver BiDi), compared with Chromium 149 and WebKit (Safari 26.5) on the same machine.
Font: Newsreader (Google Fonts, OFL), the variable Newsreader.ttf, loaded with @font-face, at 400 17px Newsreader. The paragraph has hyphens: manual.
Repro
const text = 'Sinds maart rijdt de hele vestiging elek\u00adtrisch. Dat klinkt als een afgerond project.'
await document.fonts.load('400 17px Newsreader')
const line = layoutNextLine(prepareWithSegments(text, '400 17px Newsreader'), 271)
// compare with a <p style="font: 400 17px Newsreader; width: 271px; hyphens: manual"> holding `text`
What happens
| Pretext's first line | its width | the browser's first line | the browser's width of "…vestiging elek-" | of "…vestiging elek" | |
|---|---|---|---|---|---|
| Chromium 149 | Sinds maart rijdt de hele vestiging |
238.17 | same | 275.77 | 270.78 |
| WebKit (Safari 26.5) | Sinds maart rijdt de hele vestiging |
238.53 | same | 276.12 | 271.13 |
| Firefox 160 | Sinds maart rijdt de hele vestiging elek- |
270.27 | Sinds maart rijdt de hele vestiging |
276.08 | 271.10 |
In Firefox, Pretext takes the soft-hyphen break after "elek" and counts the line as 270.27 px, which fits 271. Firefox itself measures that line at 276.08 px with its hyphen, so it doesn't break there. Pretext's width is even below Firefox's width for the same line without the hyphen (271.10), so the hyphen alone doesn't account for the gap. In Chromium and WebKit the same call predicts the browser exactly.
Effect: in a long article set in Firefox, a paragraph now and then takes one line more than Pretext planned. We saw 2 to 6 per screen width, against 0 in Chromium and WebKit. Without the soft hyphens a few lines still differed in Firefox, so plain lines may be counted a little narrow there too, but this soft-hyphen case is the one we could isolate.
We haven't checked main after 1.0.0.