Skip to content

fix: sdf kerning#762

Merged
wouterlucas merged 2 commits intomainfrom
fix/sdf-kerning
Mar 18, 2026
Merged

fix: sdf kerning#762
wouterlucas merged 2 commits intomainfrom
fix/sdf-kerning

Conversation

@jfboeve
Copy link
Copy Markdown
Collaborator

@jfboeve jfboeve commented Mar 18, 2026

What was wrong

Kerning was being added to the next cursor advance, not to the current glyph placement.
That shifts kerning by one glyph, so pairs like AV/To/Wa render too loose in SDF.
Fix applied

In SdfTextRenderer.ts:343, kerning is now computed as an offset for the current glyph.
In SdfTextRenderer.ts:355, kerning is applied to currentX before emitting the glyph.
In SdfTextRenderer.ts:377, cursor advance now uses only glyph.xadvance + letterSpacing afterward.

if (codepoint === undefined) continue;
let prevGlyphId = 0;
for (const char of text) {
const codepoint = char.codePointAt(0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@wouterlucas wouterlucas merged commit 2d58f8a into main Mar 18, 2026
2 checks passed
@wouterlucas wouterlucas deleted the fix/sdf-kerning branch March 18, 2026 14:24
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.

2 participants