Skip to content

Commit

Permalink
Fixed kerning advance in fonts with both GPOS and kern tables.
Browse files Browse the repository at this point in the history
Notably, SegoeUI on Windows has kerning advances in the kern tables, but
also has a GPOS table. The pair of characters aren't the same in each
table.
  • Loading branch information
joaodasilva committed Oct 12, 2024
1 parent 31707d1 commit 976af4f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions stb_truetype.h
Original file line number Diff line number Diff line change
Expand Up @@ -2609,14 +2609,15 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, in

STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2)
{
int xAdvance = 0;
if (info->gpos) {
int xAdvance = stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2);
if (xAdvance) return xAdvance;
}

if (info->gpos)
xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2);
else if (info->kern)
xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2);
if (info->kern)
return stbtt__GetGlyphKernInfoAdvance(info, g1, g2);

return xAdvance;
return 0;
}

STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
Expand Down

0 comments on commit 976af4f

Please sign in to comment.