8000 Fix kerning of mathtext · QuLogic/matplotlib@d6a3be2 · GitHub
[go: up one dir, main page]

Skip to content

Commit d6a3be2

Browse files
committed
Fix kerning of mathtext
The `FontInfo.num` value returned by `TruetypeFonts._get_info` is a character code, but `FT2Font.get_kerning` takes *glyph indices*, meaning that kerning was likely off in most cases.
1 parent 1995100 commit d6a3be2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,9 @@ def get_kern(self, font1: str, fontclass1: str, sym1: str, fontsize1: float,
424424
info1 = self._get_info(font1, fontclass1, sym1, fontsize1, dpi)
425425
info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi)
426426
font = info1.font
427-
return font.get_kerning(info1.num, info2.num, Kerning.DEFAULT) / 64
427+
return font.get_kerning(font.get_char_index(info1.num),
428+
font.get_char_index(info2.num),
429+
Kerning.DEFAULT) / 64
428430
return super().get_kern(font1, fontclass1, sym1, fontsize1,
429431
font2, fontclass2, sym2, fontsize2, dpi)
430432

0 commit comments

Comments
 (0)
0