Skip to content

1.0.0

Latest

Choose a tag to compare

@chenglou chenglou released this 14 Oct 12:33
· 4 commits to main since this release

Lines break where the browser breaks them in many more cases: in Chrome, Safari and Firefox, Pretext now finds where lines can break with a port of that browser's own line breaker and its data, in place of its own rules, and rich inline lays its items out as one paragraph, as a browser lays out a paragraph's spans.

Against 0.0.9, layout() at a new width is three to six times as fast and prepare() of text it has measured before 1.1 to 13 times as fast, while loading the library takes about 0.4 ms more on each page in Chrome, 0.7 ms in Safari and 1.1 ms in Firefox.

Bundles are larger: the main entry is about 40 KB gzipped, up from 16 KB, and @chenglou/pretext/rich-inline about 44 KB, up from 16 KB.

An app on 0.0.9 has to change every call of layoutNextLine() and layoutNextLineRange(), which now take the width before the cursor: swap the second and third arguments. It also has to change where it reads rich-inline cursors as places in an item's text (read a fragment's sourceStart and sourceEnd instead), where it reads segLevels, which is gone, or any field of a prepareWithSegments() handle other than segments, kinds and widths, where it passes a font string that Canvas ignores, such as an empty one, which now throws a RangeError, and where it keeps handles made by 0.0.9: prepare the text again.

CHANGELOG.md has every change and, where something went, what to do instead.