Skip to content

Commit 7f57740

Browse files
committed
Fix calculation of kerning values.
For the straight `get_kerning` call, the result should be in subpixels, since the callers (in Python) correctly scale it by 64 themselves. For the glyph advancement calculation, both `pen` (used for glyph transform and with content boxes) and kerning are in 26.6 fractional pixels. Therefore, there's no need to scale either case by 2**6 (64).
1 parent c404b9f commit 7f57740

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ft2font.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ int FT2Font::get_kerning(FT_UInt left, FT_UInt right, FT_UInt mode)
602602
FT_Vector delta;
603603

604604
if (!FT_Get_Kerning(face, left, right, mode, &delta)) {
605-
return (int)(delta.x) / (hinting_factor << 6);
605+
return (int)(delta.x) / hinting_factor;
606606
} else {
607607
return 0;
608608
}
@@ -640,7 +640,7 @@ void FT2Font::set_text(
640640
if (use_kerning && previous && glyph_index) {
641641
FT_Vector delta;
642642
FT_Get_Kerning(face, previous, glyph_index, FT_KERNING_DEFAULT, &delta);
643-
pen.x += (delta.x << 10) / (hinting_factor << 16);
643+
pen.x += delta.x / hinting_factor;
644644
}
645645
if (FT_Error error = FT_Load_Glyph(face, glyph_index, flags)) {
646646
throw_ft_error("Could not load glyph", error);

0 commit comments

Comments
 (0)