GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||
GeezerVison is showing github.com — Update dependency @chenglou/pretext to ^0.0.9 [SECURITY] by renovate[bot] · Pull Request #132 · developing-today/code Conversation
|
| Package | Change | Age | Confidence |
|---|---|---|---|
| @chenglou/pretext | ^0.0.3 → ^0.0.9 |
isRepeatedSingleCharRun() in src/analysis.ts (line 285) re-scans the entire accumulated segment on every merge iteration during text analysis, producing O(n²) total work for input consisting of repeated identical punctuation characters. An attacker who controls text passed to prepare() can block the main thread for ~20 seconds with 80KB of input (e.g., "(".repeat(80_000)).
Tested against commit 9364741d3562fcc65aacc50953e867a5cb9fdb23 (v0.0.4) on Node.js v24.12.0, Windows x64.
A standalone PoC and detailed write-up are attached below.
The buildMergedSegmentation() function (line 795) processes text segments produced by Intl.Segmenter. When consecutive non-word-like segments consist of the same single character (e.g., (, [, !, #), the code merges them into one growing segment (line 859):
// analysis.ts:849-859 - the merge branch inside the build loop } else if ( isText && !piece.isWordLike && mergedLen > 0 && mergedKinds[mergedLen - 1] === 'text' && piece.text.length === 1 && piece.text !== '-' && piece.text !== '—' && isRepeatedSingleCharRun(mergedTexts[mergedLen - 1]!, piece.text) // <- O(n) per call ) { mergedTexts[mergedLen - 1] += piece.text // append to accumulator
Before each merge, it calls isRepeatedSingleCharRun() (line 857) to verify that ALL characters in the accumulated segment match the new character:
// analysis.ts:285-291 function isRepeatedSingleCharRun(segment: string, ch: string): boolean { if (segment.length === 0) return false for (const part of segment) { // <- Iterates ENTIRE accumulated string if (part !== ch) return false } return true }
Intl.Segmenter with granularity: 'word' produces individual non-word segments for each punctuation character. For a string of N identical punctuation characters, the merge check is called N times. On the k-th call, the accumulated segment is k characters long, so isRepeatedSingleCharRun performs k comparisons.
Total work: 1 + 2 + 3 + ... + N = N(N+1)/2 = O(n^2)
prepare(text, font) // layout.ts:472
-> prepareInternal(text, font, ...) // layout.ts:424
-> analyzeText(text, profile, whiteSpace='normal') // layout.ts:430 -> analysis.ts:993
-> buildMergedSegmentation(normalized, profile, ...) // analysis.ts:1013 -> analysis.ts:795
-> for each Intl.Segmenter segment:
-> isRepeatedSingleCharRun(accumulated, newChar) // line 857 -> line 285
-> iterates entire accumulated string // O(k) per call, k growing
The simplest payload is a string of repeated ( characters:
import { prepare } from '@chenglou/pretext' // 80,000 characters -> ~20 seconds of main-thread blocking const payload = '('.repeat(80_000) prepare(payload, '16px Arial') // Blocks for ~20 seconds
Any single character that meets these criteria works:
'text' by classifySegmentBreakChar (analysis.ts:321) - i.e., not a space, NBSP, ZWSP, soft-hyphen, tab, or newlineIntl.Segmenter (word granularity)- or em-dash (explicitly excluded at lines 855-856)Working payload characters include: (, [, {, #, @, !, %, ^, ~, <, >, etc.
( characters;pretext for layout measurement blocks the main thread.prepare() is called server-side (Node.js/Bun),The attack requires no authentication, special characters, or encoding tricks -
just repeated ASCII punctuation. 80KB is well within typical text input limits.
As an application-level mitigation, callers can cap the length of text passed to
prepare() before a library-level fix is available.
Replace the O(n) full-scan verification with O(1) constant-time checks.
Since the merge only ever appends the same character to an existing repeated-char run, the invariant is maintained structurally:
Option A - Check only endpoints (O(1)):
function isRepeatedSingleCharRun(segment: string, ch: string): boolean { return segment.length > 0 && segment[0] === ch && segment[segment.length - 1] === ch }
This works for the current code because this branch only fires after earlier merge branches (CJK, Myanmar, Arabic) have been skipped, and those branches produce segments that would not start and end with the same ASCII punctuation character. However, the safety relies on an emergent property of the branch ordering and the other merge branches. Future refactors that add new merge branches or reorder the existing ones could silently break the invariant.
Option B - Track with metadata
Add a boolean lastMergeWasSingleCharRun alongside the accumulator arrays. Set it to true when a single-char merge succeeds, false when any other merge branch is taken. Check the flag instead of re-scanning the string.
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:NThis data is provided by the GitHub Advisory Database (CC-BY 4.0).
v0.0.9layoutNextLine() and layoutNextLineRange() take the width before the cursor, (prepared, maxWidth, start?), as layoutNextRichInlineLineRange() does, and give the first line without a cursor: swap the second and third arguments at every call. TypeScript reports each call left in the old order; in JavaScript, search for the two names, since a call left in the old order never returns null (#496).end and a fragment range's start and end no longer index the item's own text, and a materialized fragment's type no longer has start and end, so code that read them there no longer compiles. Read its sourceStart and sourceEnd instead, and keep the range of a line you pass back (#460, #483).prepareWithSegments() handle shows only segments, kinds and widths, all read-only: copy one before passing it on as an array or calling array methods on widths (prepared.segments.slice(), Array.from(prepared.widths)), call measureNaturalWidth() for a text's width, and read a line's width for a line's (#450).segLevels is gone: paint each paragraph of mixed-direction text as one DOM element with its direction set (#258).kinds, 'glue' is gone, a run of no-break spaces being 'text', and 'zero-width-glue' and 'control' are new (#240, #340).setLocale(locale) now sets the language text is laid out under, in place of <html lang>: pass the page's language, not the user's, or drop the call. setLocale() with no argument goes back to <html lang>, and setLocale('') no longer does (#340, #356).letterSpacing that isn't finite now throws a RangeError when preparing (#356).font string that Canvas ignores, such as '', '16px' or 'Arial 16px', now throws a RangeError when preparing: check what getComputedStyle(el).font gave before passing it on (#502).break: 'never' item in the text beside it: the item's own leading and trailing white space no longer makes a gap, and an item of only white space is an empty box as wide as its extraWidth. An item of only a zero-width space or soft hyphens, such as an editor's placeholder, gets no fragment on a line whose start consumes it, as after a space that ends the line before (#369, #460).prepareRichInline()'s list may be a box, so check its text before reading its font; a run type of your own can't carry a width; a fragment range built by hand needs gapItemIndex, and a materialized fragment sourceStart and sourceEnd too, and no start or end; and paragraphs.map(prepareRichInline) needs an arrow function, items => prepareRichInline(items) (#310, #379, #387, #460, #483).{ width } (RichInlineBox), for an image, a custom emoji, a formula or a badge inside a line, in place of a character with break: 'never' and an extraWidth that made up the rest of the object's width. A line can break before and after a box, as at an <img>, whatever text touches it, and its fragment has the box's width and no text. Heights stay yours: give each box vertical-align: top, and each line is as tall as the paragraph's line height or its tallest box, whichever is taller. prepareRichInline() now takes Array<RichInlineItem | RichInlineBox>, so code typed from its parameter checks an item's text before reading its text or font, and RichInlineItem has width?: never, so an app whose own run type carries a width beside its text no longer type-checks at prepareRichInline(): pass such runs without that field, or name it otherwise; at run time such an item still lays out as text (#387).prepareRichInline() takes an options argument, { whiteSpace: 'pre-wrap' }, for CSS white-space: pre-wrap on the paragraph, as prepare() does: every item but an atomic one keeps its spaces, tabs and newlines, spaces at a line's end hang past it across a change of style, tab stops count from the line's start, and a newline ends its line, so an editor's paragraph split into styled runs takes the lines the browser gives it. White space after an atomic item wider than the line stays on that item's line, whatever items it spans; in Firefox, such white space that runs into a tab moves to the next line with the tab. A tab counts its stops in its own item's font, as Safari does; Chrome and Firefox count them in the paragraph's font, so a tab inside a span in another font, such as a code span, can land a whole stop from theirs. paragraphs.map(prepareRichInline) no longer type-checks, since map() hands its index where the options go: write items => prepareRichInline(items) (#381, #386, #395, #419, #460).prepareRichInline()'s options argument also takes { wordBreak: 'keep-all' }, for CSS word-break: keep-all on the paragraph, as prepare() does, so Korean, Chinese and Japanese messages with mentions, bold runs or code spans break where the browser breaks them under keep-all (#379).gapItemIndex, the index of the item whose collapsed space gapBefore measures, or -1 when no space precedes the fragment on its line. A painter can draw that space inside the element of the item whose font measured it, and can tell a space that takes no room apart from no space (#310).sourceStart and sourceEnd, where the fragment's text sits in its item's text, as UTF-16 offsets: of the items Ship and it now, the fragment it now is 1 to 7. Read them where code written for 0.0.9 read the fragment's start and end as cursors into the item's own text, which they no longer are (under Changed). TypeScript that builds a fragment by hand, as a test does, now has to give it these two and gapItemIndex, and to leave out start and end, which a materialized fragment's type no longer has; a fragment range built by hand needs gapItemIndex (#460, #483).walkLineRanges(), measureLineStats(), measureNaturalWidth() and layoutNextLineRange() now also take a prepare() handle, so an app that only needs line counts, widths or cursors, such as a chat bubble shrunk to its widest line, no longer has to keep every segment's string in memory with prepareWithSegments(). layoutWithLines(), layoutNextLine() and materializeLineRange(), which return text, still need prepareWithSegments() (#449).@chenglou/pretext/rich-inline about 44 KB (107 KB), up from 16 KB (49 KB). About 23 KB gzipped of each is each browser's line-break and grapheme data with the code that reads it, which replace Pretext's own break rules and the Unicode bidi-class table that 0.0.9 bundled for segLevels. The npm package is 56 files and about 1,030 KB unpacked, where 0.0.9 was 69 files and 887 KB, 534 KB of it the demos, which have left the package (#258, #311, #340, #342, #344, #392, #394, #403, #460, #515).layout() at a new width is three to six times as fast. measureLineStats() and walkLineRanges() are 1.8 to 4.9 times as fast, layoutWithLines() 1.3 to 1.7 times and layoutNextLineRange() 1.1 to 2.2 times. prepare() of text it has measured before, as when a list prepares its messages again, is 1.1 to 13 times as fast: two to three and a half times for English text, 6 to 13 times for Chinese and Japanese, least for Thai. Text it hasn't measured before is about 1.5 to 2.1 times as fast for English, Chinese and Japanese, 1.1 to 1.6 times for messages that mix scripts, and from level to 1.7 times for Arabic and Thai. Rich inline, timed on the Markdown chat demo's paragraphs (English, most of them one item), prepares and measures new ones about 1.4 to 1.9 times as fast and ones it has measured before 2.3 to 4.8 times as fast. measureRichInlineStats() is two to three times as fast there, and walkRichInlineLineRanges() and layoutNextRichInlineLineRange() 1.1 to 1.9 times, least on paragraphs of several styled items. Worst-case text, such as letter-spaced CJK, soft hyphens among combining marks, long unbroken runs and pre-wrap text, is faster too, in prepare() and in layout().clearCache() takes 9% to 15% longer, since Pretext now asks Canvas how many glyphs Safari spaces (#513, under Fixed). The first prepare() of interface labels is slower in some languages, most of them with long words, though labels of 35 languages mixed are level or faster in the three browsers. Most of that cost is the widths a word 80px or wider now gets for each of its letters when it is first prepared, for a line narrower than the word, which cuts it between letters.pre-wrap text, tab stops now follow each browser. Chrome and Firefox count letter spacing in every stop, so a run of tabs under negative letterSpacing no longer collapses to one stop's width. A tab closer to its stop than the browser's minimum, half a space in Chrome and Safari and half a 0 in Firefox, takes the stop after it. In Firefox, which doesn't hang tabs, a word whose tab doesn't fit moves to the next line with the tab, so tab-separated text such as a pasted table or indented code wraps where Firefox wraps it (#240, #395).break: 'never') own leading or trailing white space no longer gives a gap before or after it, as browsers trim that white space inside the item's box: where only that white space stood, gapBefore is now 0, and gapItemIndex -1, where 0.0.9 measured a space in the atomic item's font. An atomic item of only white space is an empty box as wide as its extraWidth, as browsers lay out an inline-block that holds only white space, where 0.0.9 made it a collapsed space with no extraWidth (#369, #460).Intl.Segmenter, which it needs only for text in Thai, Lao, Khmer, Myanmar and the other Southeast Asian scripts written without spaces (#344).؟, ؛ or ۔ before a following word, after a ? that follows a space or a zero-width space, and after ! or ? before a symbol such as ©, ¿ or €. In Chrome and Safari they can also break after ? before $, %, +, | or -, while ! still stays with those and with a following ASCII letter or digit; in Firefox they can break after ! before a letter or digit, and ! and ? stay with a following - or |.- does so only before a letter outside ASCII in Chrome, such as é, and outside Latin-1 in Safari. In Firefox, a hyphen stays with a number after it, as in 2025-08-01 or log-2026, and a line can break after / before a letter, as in and/or or example.com/docs, though not before a number, as in 1/2.。, ,, 」, 、, ] or ゛: such a mark stays with the text before it, CJK or not, as in xxxx, or 😀。, and after CJK text so do ', /, |, ‼ and %. A word that doesn't fit a line with its mark breaks before the mark.., ,, :, ;, ), ], % or " keeps a following word or number on its line, and !, }, / or | keeps what each browser keeps: Chrome ASCII letters and digits; Safari digits, and letters only after a } that follows an ideograph or Hangul syllable; Firefox only digits after /. A time or number before closing punctuation such as a full-width comma, as in 00:00:00,, stays whole.」 or ) and a following ideograph, kana or Hangul syllable.ー after CJK text can start a line in Chrome, in Safari only on pages whose <html lang> is Japanese or Korean, and not in Firefox; where they can't, they also stay with a letter or digit before them, as in 約3ヶ月.word-break: keep-all, lines in Chrome and Firefox no longer break after ー in words such as ラーメン, nor in Chrome after an iteration mark such as 々. In Chrome and Firefox they can break before an opening bracket after CJK text, as in 서울(한국)에서, before 「 or ( after Latin letters or digits, and next to Thai text; in Chrome also next to emoji and symbols such as ★, and before an opening quotation mark or after a closing one between CJK characters, as in 他说“你好”然后; in Firefox also after a flag emoji.漢。 or 「漢, breaks between characters when it doesn't fit a line, instead of overflowing, and a run of opening brackets stays with the word after it, as in 「「tail., or ) at the start of an item stays with the word before it, and a word split across items wraps as one word, moving to the next line whole where it doesn't fit. Items without a space between them still break where the joined text allows it, such as between CJK characters, at Thai word boundaries or after -. In Chrome and Firefox, where items split a word, as when part of a Thai or Myanmar word is styled, lines end at that word's own breaks. In Safari, breaks inside each item still come from that item's own text, as Safari wraps each span, so a Thai, Lao, Khmer or Myanmar word split across items wraps like Safari's spans.gapItemIndex; an item that starts with a soft hyphen and a space keeps that space after other text on the line. White space between the soft hyphens of such an item takes room after other text in Chrome and Safari, as in one element, and a line too narrow for anything ends at its first soft hyphen. An item of only soft hyphens or a zero-width space gets no fragment on a line whose start consumes it, where 0.0.9 gave it one that took no room.end and a fragment's start and end now count segments of the item's part of the paragraph, and are only for passing back to layoutNextRichInlineLineRange() and materializeRichInlineLineRange(). On 0.0.9 they indexed the item's own prepared text, prepareWithSegments(item.text), and they no longer do: they differ, among others, for an item that starts with white space after another item's text, whose first segment is now that space; for an atomic item, which is one segment; for an item that starts inside a word whose breaks depend on the whole word, as a Thai word's do in Chrome and Firefox; and for an item with extraWidth that starts with a zero-width space, whose start is now a segment of its own before that space. A paragraph of one text item that isn't atomic and has no extraWidth keeps that text's own cursors. To find a fragment's text in its item, read the materialized fragment's sourceStart and sourceEnd (under Added): its type no longer has start and end, so TypeScript that reads them there no longer type-checks. Nor does a materialized line or fragment where a range is asked, as when a line is passed back to materializeRichInlineLineRange(): keep the range of a line you pass back.extraWidth that holds only a zero-width space, such as an empty code span kept open with one, stays on a line where only half its extraWidth, the end padding, doesn't fit, so that line's width is more than maxWidth; 0.0.9 moved it to the next line, which is where those browsers put it after a space. In Firefox, a line that ends at a space before a soft hyphen in another item reports that space in its width, one space wider than Firefox paints. Also in Firefox, where an item ends with a space and the next starts with a bidi control, such as U+200E, and another space, a one-word line that ends at the first space reports that space in its width as well, and a longer line that fits only without that space now gives up its last word to the next line, which Firefox does in some such paragraphs and not in others, so the paragraph can come out a line taller than Firefox's.prepareWithSegments() handle's kinds changed. 'glue' is gone: a segment of no-break spaces or a word joiner is now 'text', so code that compares a kind with 'glue' no longer type-checks. Two are new: 'zero-width-glue', a zero-width space or soft hyphen the browser doesn't break after, as before a combining mark, and 'control', in Safari a next-line character (U+0085) (#240, #340).prepareWithSegments() handle now shows three read-only fields and nothing else: segments, kinds and widths, each segment's width in px. The eleven others that 0.0.9's type showed are the library's own working data for laying out lines, which changes with engine fixes: six are gone (under Removed), and reading any of the rest no longer type-checks. For a text's width, call measureNaturalWidth(); for a line's, read the line's width. Each letter's width (breakableFitAdvances) and the hyphen's (discretionaryHyphenWidth) have no public equivalent. All three are read-only: to pass one on as a string[] or number[], or to write to it, copy it first, with prepared.segments.slice() or Array.from(prepared.widths). widths is typed ArrayLike<number>, with an index and a length, so for...of, spread and reduce() on it need that copy too (#450).TypeError in this version's line functions, so prepare the text again. A handle also holds a typed array now, so a deep freeze of one throws; one frozen with Object.freeze() alone, or whose objects and arrays a store froze, still lays out and materializes as it did (#340, #460, #494, #509).word-break: keep-all, and at U+2028 and U+2029 (#340).lang now breaks and measures under Chrome's UI language, as Chrome lays it out: under a Chinese UI, curly double quotes follow the line-break rules of CJK brackets, so a line can break before “ and after ”, as in 他说“OK”然后, and never right after “ or right before ” (#340).setLocale(locale) now sets the language that later prepare(), prepareWithSegments() and prepareRichInline() calls break lines and measure under, in place of the page's <html lang>, which a worker doesn't have; setLocale() without a locale goes back to <html lang>, and setLocale('') is a page without a language, where 0.0.9 took an empty string as no argument. It no longer passes the locale to Intl.Segmenter, whose word boundaries Pretext now reads only inside Thai, Lao, Khmer and Myanmar text, where no locale changes them (#340, #356).prepare(), prepareWithSegments() and prepareRichInline() now throw a RangeError for a letterSpacing that isn't finite, such as NaN or Infinity, which gave lines of width NaN, or a line per grapheme (#356).prepare(), prepareWithSegments() and prepareRichInline() now throw a RangeError for a font string that Canvas ignores, such as '', '16px', 'Arial 16px' (the family first) or 'var(--font)'. A Canvas context given such a string keeps the font it had, so 0.0.9 measured the text in whatever font was prepared last, with no error. An empty string is what getComputedStyle(el).font gives for an element that sets a longhand the shorthand can't hold, such as font-variant-numeric, or that isn't mounted yet. Each browser throws for what its own Canvas ignores: Firefox also for a size that isn't an absolute length, such as 1.5em or 100%, and Firefox and Safari for caption and the other system fonts (#502).prepare(), prepareWithSegments() and prepareRichInline() share no longer grow for as long as the page lives, which they did where text never repeats, as ids, numbers and URLs don't. Once they hold more than 262,144 segments between all fonts, the next preparation empties them before it measures anything, as clearCache() does: prepared handles keep their widths, and text prepared afterwards is measured again. For scale, 880,000 UTF-16 units of mixed-language text in one font fill 27% to 43% of that, by browser (#508).prepareWithSegments() no longer returns segLevels. Those approximate bidi levels per segment couldn't produce visual order, and computing them slowed every prepareWithSegments() and rich-inline preparation, most for Arabic and Hebrew text. To draw mixed bidi text, render each paragraph as one DOM element with its direction set, and the browser orders every line. Lines drawn separately, such as with Canvas fillText(), are each ordered as their own paragraph, so numbers or punctuation next to a line break can come out in a different order (#258).prepareWithSegments() handle no longer has lineEndFitAdvances, lineEndPaintAdvances, breakablePreferredBreaks, spacingGraphemeCounts or chunks, fields README never documented but 0.0.9's published type showed; none has a public equivalent (#255, #340).pages/demos and pages/assets). They live in the repository (#342).AV, the cut can still fall a letter from Firefox's and the word take a line more or fewer. Firefox also keeps the letters of a ligature, such as fi in fonts that join it or Armenian ու, on one line, and moves them to the next together where they don't fit; Pretext can still cut between them in a word of more than 96 letters. The widths for this are measured when such a word is first prepared, the cost new labels in languages with long words pay (under Changed) (#340, #435).break: 'never' item that takes no room, or a box of width 0, that falls past the end of a full line, as after a space that doesn't fit, now lands on the line Firefox puts it on. It stays at the end of the full line where it is the paragraph's last item, where a box or chip with a width follows it, or text without extraWidth that starts with a space, and in pre-wrap after spaces that hang. It starts the next line where text or an item with extraWidth follows it directly, or where the white space before it follows text already wider than the line. It used to start the next line in every case, which could give the paragraph a line more than Firefox lays out and put the item's fragment, and the height an app gives each line from its boxes, on the wrong line (#387, #405).A, T or Y, and in some fonts the space after many words, which Chrome's Canvas doesn't report for words measured apart, so a line with several such words was up to a few pixels too wide: a paragraph of card-length text took a line more than Chrome gave it at about one width in 600 in Arial, and one in 75 in Gill Sans, and a bubble sized to its widest line was that much too wide. Pretext now reads that kerning from Canvas: the first text with a space in a font costs two more measureText calls, which tell whether the font kerns the space, and only a font that does costs more, up to three calls for each distinct first or last character of its words other than ideographs, kana and Hangul syllables, so the first paragraphs in such a font make the most extra calls and later ones next to none. Where a line ends at a word that kerns with the space after it, the word is measured without that kerning, as Chrome lays it out in centered, right-aligned, justified or underlined text and in text directly inside an element with a background; in plain start-aligned text Chrome keeps the kerning there, so such a line can still wrap one word sooner than Chrome, as before, and never later. A font that kerns only characters outside ASCII against the space, as Tamil MN and Malayalam MN do, and text that holds right-to-left letters or a bidi control other than LRM, measure as before. In rich inline, a collapsed space at an item's start or end is measured with that item's text beside it, so gapBefore and the line's width hold this kerning too: A and a space in 16px Arial are 0.88px narrower (#408, #423, #426, #460).layout() said. Under a font list of one family that Chrome's Canvas doesn't shape as a whole, such as "Helvetica Neue" alone, kana that the system's fallback font draws still measure apart: name a Japanese font after it (#497).whiteSpace: 'normal' now takes no room, as Firefox draws it, inside a rich-inline item and at its start or end too: ab\rcd is as wide as abcd, and a line can still end after ab. Before, it took the room of a space. \r\n is still one space. White space that starts the next rich-inline item after one is measured in that item's own font and letter spacing, as Firefox draws it, where the item that held the carriage return or form feed measured it (#399, #460).whiteSpace: 'normal' now takes no room, as Safari draws it, inside a rich-inline item and at its start or end too: ab\rcd is as wide as abcd, and no line ends at the carriage return in text that is all Latin-1; where the text holds characters outside it, such as Cyrillic, Arabic or Chinese letters, a line can end after the carriage return where Safari ends one, as in бв\rcd and not in бв\r12. On 0.0.9 it took the room of a space and a line could end at it, so a line holding one measured a space too wide and a paragraph could come out a line taller than Safari's. \r\n is still one space, and white space that starts the next rich-inline item after a carriage return is measured in that item's own font and letter spacing. One kind of font goes the other way: where the first installed family of a font list is monospace or one of macOS's own fixed-pitch fonts, Menlo, Monaco, Courier, Andale Mono or PT Mono, Safari gives the carriage return a character's width. For one carriage return between two letters the space 0.0.9 gave it was as wide; now a line holding one measures a character too narrow in those fonts, and a paragraph can come out a line shorter than Safari's. Courier New, ui-monospace and web fonts aren't among them (#455, #460).ab, space, soft hyphen, space, cd, now take the room of one space, as Firefox collapses them into one, instead of two (#399).⚡ in Menlo, ⬜ in Inter or ⚪ in Hiragino Sans, or one before the text-presentation selector U+FE0E. A pictograph written with no U+FE0F after it that the system's emoji font draws all the same, such as U+1F336 🌶 or U+1F5D1 🗑 in Arial, and an emoji sequence that the emoji font has no glyph for, and draws as two emoji, no longer measure 4-5px wider than drawn (#398).letterSpacing no longer adds space after the letters of Arabic, Persian, Urdu and the other joined scripts (Syriac, N'Ko, Mandaic, Mongolian, Phags-pa, Hanifi Rohingya), as the browsers add none: Chrome, which also leaves out the digits, brackets and punctuation inside such text and spaces only its spaces, and Firefox, which keeps spacing those. Such text measured too wide by the spacing times its letters, or too narrow under negative spacing, so its lines broke elsewhere than the browser's. Safari spaces each glyph it draws, and so does Pretext there now (below). This is Chrome's rule since 149. Chrome 138 to 148 leave those spaces unspaced too, and Chromium before 138 spaces every letter, as Pretext did; on those, as in an older Electron app or WebView, Pretext's width for such text is now off by the spacing times its spaces, or times its letters (#397).letterSpacing now counts as Firefox lays it out, in whole steps of 1/60px: at -0.08px each character takes -5/60px, and a spacing under 1/120px none. A spacing between steps, such as -0.08px or one computed from an em value, made each line a little wider or narrower than Firefox's, 0.1px over 30 characters at -0.08px, so a word could land on another line (#397).letterSpacing in a font with fi, fl or ffi ligatures, such as Roboto, Futura, Hoefler Text or Iowan Old Style, now measures as wide as the browser draws it. Browsers turn those ligatures off under any letter spacing, and Pretext measured the words with them, up to 1.3px too narrow per word at 16px, so a line could hold a word the browser wraps and an element sized to the widest line could wrap again. Safari's Canvas can't measure such text without its ligatures, so there the widths stay that much too narrow (#397).letterSpacing now adds its space after each glyph Safari draws, as Safari does, in text it shapes as complex text, such as Hindi and the other Indic scripts, Thai, Khmer and Arabic, and a word with a combining accent. Pretext added it after each grapheme, so a Devanagari consonant drawn with its vowel sign as two glyphs measured a spacing too narrow and Arabic's lam-alef, two letters drawn as one glyph, a spacing too wide: a line could hold a word Safari wraps, and a paragraph come out a line shorter than Safari's. Where a font joins two letters of such text into an optional ligature, which Safari's page turns off under letter spacing and its Canvas keeps, the pair still measures too narrow, now by a spacing as well: letter-spaced Arabic in Al Nile or Damascus, which join common pairs, breaks elsewhere than Safari's a little more often than it did (16 of 24 paragraph and width pairs tried, where 13 did). Counting the glyphs costs Safari one more measureText call for each prefix of such a word that is new to its font, about twice the calls of 0.0.9 for letter-spaced Hindi and Arabic paragraphs, the first time they are prepared and each time after clearCache(). Text without letterSpacing, and Chrome and Firefox, measure as before (#513).- of a compound such as contre-pro\u00ADposition, a dash, or a break between Chinese or Japanese characters, as the browsers lay it out, instead of keeping the hyphen past the line's end; so does a line whose word holds a control character. Text with many soft hyphens, such as hyphenated German, often took other breaks than the browser's, sometimes with a line fewer. With letterSpacing, Chrome's visible hyphen no longer gets letter spacing of its own (#239, #340, #396, #446, #515).-. Some fonts draw the two differently, such as Inter, whose U+2010 is 1.6px narrower at 16px, and Chinese fonts such as Songti SC, whose U+2010 is a full em wide, so such lines now break where the browser breaks them and report the width it paints. The line's text still ends with - (#396).pre-wrap and inside a rich-inline item, where 0.0.9 kept the text after it on the same line. A line holding only soft hyphens or spaces between two separators counts as a line (#340, #349, #369, #381). cd, which Canvas fillText() or white-space: pre painted one space to the right. It now starts after the space, as the browsers start that line and as layoutWithLines() does. At any letter spacing, a rich line's first fragment now starts after the spaces and soft hyphens a line start skips, where its start cursor used to sit before them (#380).materializeLineRange() and materializeRichInlineLineRange(), given a range that ends past its text, such as one kept from a longer text that was since prepared again, now build the text up to its end. Before, each missing segment added undefined to the line's text, and a range ending at segment Infinity ran until memory ran out (#353).white-space: pre-wrap, a line holding only soft hyphens before a newline, at the start of the text or after another newline, now counts as a line, as browsers draw it, instead of disappearing (#349).serif, sans-serif, cursive, fantasy or monospace, or falling back to one of them, now measures in the font Safari draws it with there, such as Apple SD Gothic Neo for sans-serif on a ko page and Menlo for monospace on an en page, instead of the font those names give a page without a language. WebKit on other systems, such as GNOME Web, a Tauri app on Linux or Playwright's WebKit there, gives those names the same fonts on the page as in Canvas, and Pretext measures them as given there, as 0.0.9 did (#340, #505).text-spacing-trim gives it, also where a rich-inline item boundary splits the pair[!IMPORTANT]
✂ PR body was truncated to here.
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
0378752 to
fc62b79
Compare
fc62b79 to
da4100a
Compare
da4100a to
c7fd61b
Compare
c7fd61b to
b1c05fe
Compare
b1c05fe to
60d0d3e
Compare
60d0d3e to
5e25e05
Compare
bed9d5c to
c426bfd
Compare
c426bfd to
2acedce
Compare
2acedce to
4fa589c
Compare
4fa589c to
8561333
Compare
8561333 to
2ea7ee9
Compare
2ea7ee9 to
f1ee73c
Compare
29c2cf1 to
e65e1bf
Compare
e65e1bf to
11c0dff
Compare
a7ee2c7 to
11674f4
Compare
f6122a7 to
30523ed
Compare
Edited/Blocked NotificationRenovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. You can manually request rebase by checking the rebase/retry box above. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.