Skip to content

Commit 6c7b9d0

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 00e3834 commit 6c7b9d0

21 files changed

+3032
-2769
lines changed

Diff for: lib/matplotlib/_mathtext.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,9 @@ def get_kern(self, font1: str, fontclass1: str, sym1: str, fontsize1: float,
423423
info1 = self._get_info(font1, fontclass1, sym1, fontsize1, dpi)
424424
info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi)
425425
font = info1.font
426-
return font.get_kerning(info1.num, info2.num, Kerning.DEFAULT) / 64
426+
return font.get_kerning(font.get_char_index(info1.num),
427+
font.get_char_index(info2.num),
428+
Kerning.DEFAULT) / 64
427429
return super().get_kern(font1, fontclass1, sym1, fontsize1,
428430
font2, fontclass2, sym2, fontsize2, dpi)
429431

0 commit comments

Comments
 (0)