@weasel-js/text-shaping 1.14.2 → 1.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,10 +21,14 @@ registerBidi(bidi);
21
21
  registerShaper(await loadShaper()); // once, at startup, before text is laid out
22
22
  ```
23
23
 
24
- Shaping reaches text set in a face registered with `registerFontOutlines` from TrueType or
25
- OpenType bytes: its glyphs are drawn from the outlines by index, so any glyph a shaping
26
- produces can be drawn. Text served by a baked or canvas atlas looks glyphs up by character
27
- and is laid out as before; so is a face loaded from WOFF, whose bytes HarfBuzz cannot read.
24
+ Shaping reaches text set in a face whose TrueType or OpenType bytes are registered with
25
+ `registerFontOutlines`. That face can also be a baked atlas (`registerFont`) or a canvas face
26
+ (`registerCanvasFont`): register the same family and variant with `registerFontOutlines` too,
27
+ and its text is shaped from that file. A baked atlas must be cut from the same file, or its
28
+ advances disagree with the shaper's. On an atlas face, a letter the shaping leaves as its own
29
+ glyph still draws from the atlas; a shaped cluster (a conjunct, a joining form, a placed mark)
30
+ draws from its outline, and on a canvas face below the outline size from a tile baked from that
31
+ outline. A face loaded from WOFF, whose bytes HarfBuzz cannot read, is laid out as before.
28
32
  Right-to-left text also needs the bidi engine, which puts its letters in visual order.
29
33
 
30
34
  With a shaper registered, `fontVariantCaps: 'small-caps'` on a face that has an `smcp`
@@ -50,12 +54,11 @@ against it.
50
54
 
51
55
  ## Bundling
52
56
 
53
- harfbuzzjs finds its `.wasm` beside its own module with `new URL('harfbuzz.wasm',
54
- import.meta.url)`. Vite needs no configuration for it: a production build emits the file
55
- as an asset and points the URL at it, and the dev server's dependency pre-bundle points the
56
- URL back at the file in `node_modules`.
57
+ The package ships HarfBuzz's WebAssembly as `dist/harfbuzz.wasm` and finds it with
58
+ `new URL('harfbuzz.wasm', import.meta.url)` from its own JavaScript. Vite needs no
59
+ configuration for it: a production build emits the file as an asset and points the URL at
60
+ it. In Node, `loadShaper` reads the copy in the `harfbuzzjs` package instead.
57
61
 
58
- harfbuzzjs awaits at its module's top level, so the bundle must target ES2022 or later.
59
- Loading it through `loadShaper`'s dynamic `import()` does not hide that from a bundler:
60
- esbuild (and Vite 7 and earlier, which pre-bundle with it) refuses a lower target, while
61
- Vite 8 warns and leaves the `await` in place.
62
+ No top-level `await` reaches the bundle, so any target esbuild accepts works, ES2020
63
+ included: harfbuzzjs's JavaScript is vendored here with its initialization left to
64
+ `loadShaper`, since its published module awaits the WebAssembly at the top level.