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

Skip to content

Commit 85f4377

Browse files
committed
Keep a reference to non-subsetted font for XObjects
1 parent a95f2b6 commit 85f4377

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,9 @@ def embedTTFType42(font, characters, descriptor):
12391239
os.stat(filename).st_size, fontdata.getbuffer().nbytes
12401240
)
12411241

1242+
# We need this ref for XObjects
1243+
full_font = font
1244+
12421245
# reload the font object from the subset
12431246
# (all the necessary data could probably be obtained directly
12441247
# using fontLib.ttLib)
@@ -1325,10 +1328,10 @@ def embedTTFType42(font, characters, descriptor):
13251328
glyph_ids = []
13261329
for ccode in characters:
13271330
if not _font_supports_char(fonttype, chr(ccode)):
1328-
gind = font.get_char_index(ccode)
1331+
gind = full_font.get_char_index(ccode)
13291332
glyph_ids.append(gind)
13301333

1331-
bbox = [cvt(x, nearest=False) for x in font.bbox]
1334+
bbox = [cvt(x, nearest=False) for x in full_font.bbox]
13321335
rawcharprocs = _get_pdf_charprocs(filename, glyph_ids)
13331336
for charname in sorted(rawcharprocs):
13341337
stream = rawcharprocs[charname]

0 commit comments

Comments
 (0)