Skip to content

Commit 73bd5f5

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 788a0e8 commit 73bd5f5

21 files changed

+5183
-4716
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,9 @@ def get_kern(self, font1: str, fontclass1: str, sym1: str, fontsize1: float,
426426
info1 = self._get_info(font1, fontclass1, sym1, fontsize1, dpi)
427427
info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi)
428428
font = info1.font
429-
return font.get_kerning(info1.num, info2.num, Kerning.DEFAULT) / 64
429+
return font.get_kerning(font.get_char_index(info1.num),
430+
font.get_char_index(info2.num),
431+
Kerning.DEFAULT) / 64
430432
return super().get_kern(font1, fontclass1, sym1, fontsize1,
431433
font2, fontclass2, sym2, fontsize2, dpi)
432434

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy