Skip to content

feat: expose fontKerning option in prepare() - #216

Open
alexiskowalski wants to merge 5 commits into
chenglou:mainfrom
alexiskowalski:feat/font-kerning-prepare-199
Open

feat: expose fontKerning option in prepare()#216
alexiskowalski wants to merge 5 commits into
chenglou:mainfrom
alexiskowalski:feat/font-kerning-prepare-199

Conversation

@alexiskowalski

Copy link
Copy Markdown

Summary

Fixes #199 by letting prepare() / prepareWithSegments() set canvas fontKerning while measuring.

Pretext's value is accurate measurement without DOM reflow, but measurement was always locked to the browser default kerning (auto). Consumers that paint with font-kerning: none / ctx.fontKerning = 'none' could not align widths.

Changes

  • Add PrepareOptions.fontKerning?: 'auto' | 'normal' | 'none' (default 'auto').
  • Apply ctx.fontKerning in getFontMeasurementState on every prepare.
  • Key the segment metric cache by font + kerning mode (default path keeps the plain font key).
  • Document in README / CHANGELOG; unit tests with a fake canvas that models a kerning pair.

Test plan

  • Unit: fontKerning: 'none' widens AV vs default; caches stay isolated.
  • Package test suite / CI

f1vwpbleiia7ie added 5 commits August 8, 2026 22:59
Signed-off-by: f1vwpbleiia7ie <f1vwpbleiia7ie@users.noreply.github.com>
Signed-off-by: f1vwpbleiia7ie <f1vwpbleiia7ie@users.noreply.github.com>
Signed-off-by: f1vwpbleiia7ie <f1vwpbleiia7ie@users.noreply.github.com>
Signed-off-by: f1vwpbleiia7ie <f1vwpbleiia7ie@users.noreply.github.com>
Signed-off-by: f1vwpbleiia7ie <f1vwpbleiia7ie@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose fontKerning option in prepare() — align measurement with rendering

1 participant