Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7945e5b

Browse files
committed
:s/char_idx/glyph_idx
... to avoid confusion with the unicode codepoint. FreeType's doc mostly uses "glyph index", except that the function to get it is called FT_Get_Char_Index...
1 parent 2c47630 commit 7945e5b

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

lib/matplotlib/_text_layout.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
def layout(string, font, *, kern_mode=KERNING_DEFAULT):
99
"""
1010
Render *string* with *font*. For each character in *string*, yield a
11-
(character-index, x-position) pair. When such a pair is yielded, the
12-
font's glyph is set to the corresponding character.
11+
(glyph-index, x-position) pair. When such a pair is yielded, the font's
12+
glyph is set to the corresponding character.
1313
1414
Parameters
1515
----------
@@ -22,17 +22,17 @@ def layout(string, font, *, kern_mode=KERNING_DEFAULT):
2222
2323
Yields
2424
------
25-
character_index : int
25+
glyph_index : int
2626
x_position : float
2727
"""
2828
x = 0
29-
last_char_idx = None
29+
last_glyph_idx = None
3030
for char in string:
31-
char_idx = font.get_char_index(ord(char))
32-
kern = (font.get_kerning(last_char_idx, char_idx, kern_mode)
33-
if last_char_idx is not None else 0) / 64
31+
glyph_idx = font.get_char_index(ord(char))
32+
kern = (font.get_kerning(last_glyph_idx, glyph_idx, kern_mode)
33+
if last_glyph_idx is not None else 0) / 64
3434
x += kern
35-
glyph = font.load_glyph(char_idx, flags=LOAD_NO_HINTING)
36-
yield char_idx, x
35+
glyph = font.load_glyph(glyph_idx, flags=LOAD_NO_HINTING)
36+
yield glyph_idx, x
3737
x += glyph.linearHoriAdvance / 65536
38-
last_char_idx = char_idx
38+
last_glyph_idx = glyph_idx

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,8 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
625625
self.set_font(ps_name, prop.get_size_in_points())
626626

627627
thetext = '\n'.join(
628-
'%f 0 m /%s glyphshow' % (x, font.get_glyph_name(char_idx))
629-
for char_idx, x in _text_layout.layout(s, font))
628+
'%f 0 m /%s glyphshow' % (x, font.get_glyph_name(glyph_idx))
629+
for glyph_idx, x in _text_layout.layout(s, font))
630630
self._pswriter.write(f"""\
631631
gsave
632632
{x:f} {y:f} translate

0 commit comments

Comments
 (0)