prepare()/prepareWithSegments()accept afontFeatureSettingsoption (a CSSfont-feature-settingsvalue), and rich-inline items accept a per-itemfontFeatureSettings, so text measured with OpenType features — stylistic sets, slashed zero, pinned alternates — wraps where the browser wraps it. Feature measurement uses a hidden DOM canvas, so it needs a document; without one the option is ignored.
- Safari soft-hyphen wrapping now follows the same strict insertion-point behavior across
layout(), rich-line, and streaming APIs. The Safari compatibility profile was revalidated on Safari 26.4, after previously being validated through Safari 26.3.1.
- Segment measurement now includes a short following context as shaping lookahead — through spaces up to the next visible letter — so cross-boundary kerning and required ligatures (e.g. Hebrew fonts that only ligate a word-final letter when a following letter shares the shaping buffer, even across a space) no longer overstate widths and wrap lines browsers keep whole.
- The published package now ships declaration maps, so editor go-to-definition and programmatic TypeScript source tracing land in the shipped
.tssource instead of the.d.tsfiles.
- Word-internal keyboard and Unicode symbol runs in long words now stay with surrounding text the way browsers break them, while browser-break symbols stay breakable (#169).
- Overlong hyphenated runs now prefer browser-like dash breakpoints before falling back to emergency grapheme breaks (#89).
- The package now declares itself side-effect-free so bundlers can tree-shake unused entrypoints (#160).
layoutNextLine()andlayoutNextLineRange()now avoid redundant chunk lookup in chunk-heavy manual layout paths (#140).
{ wordBreak: 'keep-all' }now handles no-space mixed Latin, numeric, and CJK text more like browsers.- No-space punctuation chains now stay together for non-ASCII word-like text too, instead of only ASCII words.
- Opening punctuation such as
¡,¿, German low quotes, and⸘now stays with the following word instead of dangling at line end (#165). - Numeric prefix/postfix symbols like
$,%,€,+,−, and°now stay attached to adjacent text the way browser line breaking does (#105). - Soft-hyphen breaks now stay at the soft-hyphen insertion point instead of pulling post-hyphen graphemes onto the broken line (#162).
- Line geometry now preserves browser-style terminal letter spacing, including rich-inline item boundaries and visible soft-hyphen breaks (#171).
- Rich-inline item boundaries no longer overflow the requested width after a forced-progress break (#132).
- The markdown chat demo now drops parsed link URLs unless they resolve to HTTP(S) hrefs (#168).
- Numeric CSS-pixel
letterSpacingsupport onprepare(),prepareWithSegments(), and each existing rich-inline item (#108, #156).
- CJK text followed by opening bracket annotations now wraps like browsers instead of leaving the opening bracket on the previous line (#148).
- Geometry-first rich line helpers for manual layout work:
measureLineStats(),measureNaturalWidth(),layoutNextLineRange(), andmaterializeLineRange(). @chenglou/pretext/rich-inline, a narrow helper for inline-only rich text, mentions/chips, and browser-like boundary whitespace collapse.{ wordBreak: 'keep-all' }support onprepare()/prepareWithSegments()for CJK and Hangul text.- A virtualized markdown chat demo for rich inline text and
pre-wraplayout.
- Prepare-time analysis is more resilient on long mixed-script, CJK, Arabic, repeated-punctuation, and other degenerate inputs.
- Mixed CJK-plus-numeric runs, keep-all mixed-script boundaries, and long breakable runs now stay closer to browser behavior.
- Rich-path bidi metadata and CJK detection now handle the relevant astral Unicode ranges correctly.
- A justification comparison demo that shows native CSS justification, greedy hyphenation, and a Knuth-Plass-style paragraph layout side by side.
- Rich layout is faster on chunk-heavy and long-breakable text.
layout(),layoutWithLines(), andlayoutNextLine()stay aligned on narrowZWSP/ grapheme-breaking edge cases.- The justification comparison demo no longer paints justified lines wider than their column.
- npm now publishes built ESM JavaScript from
dist/instead of exposing raw TypeScript source as the package entrypoint. - TypeScript consumers now pick up shipped declaration files automatically from the published package, while plain JavaScript consumers can install and import the package without relying on dependency-side TypeScript transpilation.
{ whiteSpace: 'pre-wrap' }mode for textarea-like text, preserving ordinary spaces, tabs, and hard breaks.
- Safari line breaking is more accurate for narrow soft-hyphen and breakable-run cases.
Initial public npm release of @chenglou/pretext.
prepare()andlayout()as the core fast path for DOM-free multiline text height prediction.- Rich layout APIs including
prepareWithSegments(),layoutWithLines(),layoutNextLine(), andwalkLineRanges()for custom rendering and manual layout.