Skip to content

Fix/canvas text align fontsize#203

Open
salmanmkc wants to merge 2 commits intogoogle:mainfrom
salmanmkc:fix/canvas-text-align-fontsize
Open

Fix/canvas text align fontsize#203
salmanmkc wants to merge 2 commits intogoogle:mainfrom
salmanmkc:fix/canvas-text-align-fontsize

Conversation

@salmanmkc
Copy link
Contributor

@salmanmkc salmanmkc commented Mar 22, 2026

Fixes #95

The canvas text fallback was hardcoded to textAlign='center' and textBaseline='middle', ignoring the properties that SDF text handles correctly. Now maps textAlign to the correct draw X position and anchorY to the matching textBaseline and draw Y.

Similar to #202 I've added a test harness setup, but we can probably rebase after whichever is merged in first.

Test harness issue: #205

Fixes google#95. Canvas text rendering was hardcoded to textAlign='center'
and textBaseline='middle', ignoring the configured properties. Now
uses this.textAlign for horizontal alignment and maps this.anchorY
to the correct canvas textBaseline and draw position.
Adds vitest + jsdom as test infrastructure. Includes tests verifying
that canvas-based text rendering respects the textAlign and anchorY
properties instead of hardcoding center alignment.
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.

Font size doesn't work with canvas-based text.

1 participant