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

Skip to content

Commit 5656d11

Browse files
authored
Merge pull request #20974 from anntzer/gn
Rename symbol_name to glyph_name where appropriate.
2 parents 4e21dcf + a1c69dd commit 5656d11

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True):
264264
if bunch is not None:
265265
return bunch
266266

267-
font, num, symbol_name, fontsize, slanted = \
267+
font, num, glyph_name, fontsize, slanted = \
268268
self._get_glyph(fontname, font_class, sym, fontsize, math)
269269

270270
font.set_size(fontsize, dpi)
@@ -292,7 +292,8 @@ def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True):
292292
fontsize = fontsize,
293293
postscript_name = font.postscript_name,
294294
metrics = metrics,
295-
symbol_name = symbol_name,
295+
glyph_name = glyph_name,
296+
symbol_name = glyph_name, # Backcompat alias.
296297
num = num,
297298
glyph = glyph,
298299
offset = offset
@@ -358,7 +359,7 @@ def __init__(self, *args, **kwargs):
358359
_slanted_symbols = set(r"\int \oint".split())
359360

360361
def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
361-
symbol_name = None
362+
glyph_name = None
362363
font = None
363364
if fontname in self.fontmap and sym in latex_to_bakoma:
364365
basename, num = latex_to_bakoma[sym]
@@ -373,13 +374,13 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
373374
if font is not None:
374375
gid = font.get_char_index(num)
375376
if gid != 0:
376-
symbol_name = font.get_glyph_name(gid)
377+
glyph_name = font.get_glyph_name(gid)
377378

378-
if symbol_name is None:
379+
if glyph_name is None:
379380
return self._stix_fallback._get_glyph(
380381
fontname, font_class, sym, fontsize, math)
381382

382-
return font, num, symbol_name, fontsize, slanted
383+
return font, num, glyph_name, fontsize, slanted
383384

384385
# The Bakoma fonts contain many pre-sized alternatives for the
385386
# delimiters. The AutoSizedChar class will use these alternatives
@@ -556,8 +557,8 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
556557
glyphindex = font.get_char_index(uniindex)
557558
slanted = False
558559

559-
symbol_name = font.get_glyph_name(glyphindex)
560-
return font, uniindex, symbol_name, fontsize, slanted
560+
glyph_name = font.get_glyph_name(glyphindex)
561+
return font, uniindex, glyph_name, fontsize, slanted
561562

562563
def get_sized_alternatives_for_symbol(self, fontname, sym):
563564
if self.cm_fallback:
@@ -854,7 +855,7 @@ def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True):
854855

855856
if found_symbol:
856857
try:
857-
symbol_name = font.get_name_char(glyph)
858+
glyph_name = font.get_name_char(glyph)
858859
except KeyError:
859860
_log.warning(
860861
"No glyph in standard Postscript font {!r} for {!r}"
@@ -864,7 +865,7 @@ def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True):
864865
if not found_symbol:
865866
glyph = '?'
866867
num = ord(glyph)
867-
symbol_name = font.get_name_char(glyph)
868+
glyph_name = font.get_name_char(glyph)
868869

869870
offset = 0
870871

@@ -890,7 +891,8 @@ def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True):
890891
fontsize = fontsize,
891892
postscript_name = font.get_fontname(),
892893
metrics = metrics,
893-
symbol_name = symbol_name,
894+
glyph_name = glyph_name,
895+
symbol_name = glyph_name, # Backcompat alias.
894896
num = num,
895897
glyph = glyph,
896898
offset = offset

lib/matplotlib/backends/backend_pdf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,12 +1063,12 @@ def createType1Descriptor(self, t1font, fontfile):
10631063

10641064
return fontdescObject
10651065

1066-
def _get_xobject_symbol_name(self, filename, symbol_name):
1066+
def _get_xobject_glyph_name(self, filename, glyph_name):
10671067
Fx = self.fontName(filename)
10681068
return "-".join([
10691069
Fx.name.decode(),
10701070
os.path.splitext(os.path.basename(filename))[0],
1071-
symbol_name])
1071+
glyph_name])
10721072

10731073
_identityToUnicodeCMap = b"""/CIDInit /ProcSet findresource begin
10741074
12 dict begin
@@ -1204,7 +1204,7 @@ def get_char_width(charcode):
12041204
# Send the glyphs with ccode > 255 to the XObject dictionary,
12051205
# and the others to the font itself
12061206
if charname in multi_byte_chars:
1207-
name = self._get_xobject_symbol_name(filename, charname)
1207+
name = self._get_xobject_glyph_name(filename, charname)
12081208
self.multi_byte_charprocs[name] = charprocObject
12091209
else:
12101210
charprocs[charname] = charprocObject
@@ -1347,7 +1347,7 @@ def embedTTFType42(font, characters, descriptor):
13471347
self.currentstream.write(stream)
13481348
self.endStream()
13491349

1350-
name = self._get_xobject_symbol_name(filename, charname)
1350+
name = self._get_xobject_glyph_name(filename, charname)
13511351
self.multi_byte_charprocs[name] = charprocObject
13521352

13531353
# CIDToGIDMap stream
@@ -2417,8 +2417,8 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
24172417

24182418
def _draw_xobject_glyph(self, font, fontsize, glyph_idx, x, y):
24192419
"""Draw a multibyte character from a Type 3 font as an XObject."""
2420-
symbol_name = font.get_glyph_name(glyph_idx)
2421-
name = self.file._get_xobject_symbol_name(font.fname, symbol_name)
2420+
glyph_name = font.get_glyph_name(glyph_idx)
2421+
name = self.file._get_xobject_glyph_name(font.fname, glyph_name)
24222422
self.file.output(
24232423
Op.gsave,
24242424
0.001 * fontsize, 0, 0, 0.001 * fontsize, x, y, Op.concat_matrix,

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,12 +701,12 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
701701
lastfont = font.postscript_name, fontsize
702702
self._pswriter.write(
703703
f"/{font.postscript_name} {fontsize} selectfont\n")
704-
symbol_name = (
704+
glyph_name = (
705705
font.get_name_char(chr(num)) if isinstance(font, AFM) else
706706
font.get_glyph_name(font.get_char_index(num)))
707707
self._pswriter.write(
708708
f"{ox:f} {oy:f} moveto\n"
709-
f"/{symbol_name} glyphshow\n")
709+
f"/{glyph_name} glyphshow\n")
710710
for ox, oy, w, h in rects:
711711
self._pswriter.write(f"{ox} {oy} {w} {h} rectfill\n")
712712
self._pswriter.write("grestore\n")

0 commit comments

Comments
 (0)