feat: infer and apply CSS letter-spacing - #65
Merged
Merged
Conversation
The renderer reads letter-spacing from the container's computed style (alongside font-size, line-height, color) and applies it to the animated strokes, re-measuring on change via the sentinel transition. Spacing is inserted between clusters in the shaper pen-walk and picked up from the DOM-measured offsets on the char-keyed fallback path, keeping wrapping, glyph positions, and drawn text in sync. Adds a Studio slider (persisted to the URL as ls) and a textToSvg letterSpacing option. Closes #62
Contributor
TegamiThis repository uses Tegami to manage releases. When your changes affect published packages, add a changelog file under Create a changelog → · Changelog format Release preview
Changelogs in this PR
Run Managed by Tegami. |
A prior lockfile change pulled in multiple @types/node versions (22, 24, 25, 26). With the root tsconfig's node resolution, 'node:child_process' resolved to a different copy depending on platform — on Linux (CI) it picked one where ChildProcess/ChildProcessByStdio lost its EventEmitter base, so 'proc.on(...)' in generate-fonts.ts and derive-korean-chars.ts failed with TS2339/TS7006. macOS happened to resolve a working copy, so 'bun typecheck' passed locally while CI stayed red. Pin @types/node to a single 22.20.1 via overrides so resolution is deterministic across platforms. Verified with a frozen install + full 'bun typecheck' in the Linux (oven/bun) image CI uses.
; Conflicts: ; bun.lock ; package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #62
What
Adds first-class letter-spacing support to the
tegakirenderer, plus a Studio slider to control it.Many of the handwritten fonts ship tracked out quite wide (the issue's motivation), and there was no way to tighten or loosen the spacing. Now the component infers
letter-spacingfrom CSS — the same way it already picks upfont-size,line-height, andcolor— and applies it to the rendered strokes.How
Renderer (
tegaki)letter-spacingfrom the container's computed style in_measure(), and re-measures reactively when it changes (the hidden sentinel now inheritsletter-spacingand transitions on it, matching the existing font-size/line-height/color mechanism). It's added to the layout-cache key so a spacing-only change forces a re-layout.applyShaperPositions, so it accumulates just like the browser applied it to the overlay used for line-breaking.letter-spacingvia CSS.textToSvgexport gained a matchingletterSpacingoption.Studio (
@tegaki/website)ls.useShaperthroughStandaloneTextPreviewso/previewhonors the documentedhbparam (previously ignored) — needed for the non-shaper visual test and consistent with the generator.Correctness across scripts
Verified in-browser with the overlay on (canvas strokes vs. the browser-spaced DOM text):
Tests
textToSvgletter-spacing behavior (widens layout, shifts later glyphs, leaves the first glyph put).-darwin+-linuxbaselines:letter-spacing-shaper,letter-spacing-non-shaper,letter-spacing-rtl. Linux baselines generated and re-verified in thev1.61.1-nobleCI image.bun checksgreen.