Skip to content

Commit 58ddc36

Browse files
authored
Merge pull request #10046 from anntzer/svg-font
Add missing decode() in svg font embedding path.
2 parents 3441571 + dfc856a commit 58ddc36

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,10 +1141,10 @@ def embedTTFType42(font, characters, descriptor):
11411141
# You are lost in a maze of TrueType tables, all different...
11421142
sfnt = font.get_sfnt()
11431143
try:
1144-
ps_name = sfnt[(1, 0, 0, 6)].decode('macroman') # Macintosh scheme
1144+
ps_name = sfnt[1, 0, 0, 6].decode('mac_roman') # Macintosh scheme
11451145
except KeyError:
11461146
# Microsoft scheme:
1147-
ps_name = sfnt[(3, 1, 0x0409, 6)].decode('utf-16be')
1147+
ps_name = sfnt[3, 1, 0x0409, 6].decode('utf-16be')
11481148
# (see freetype/ttnameid.h)
11491149
ps_name = ps_name.encode('ascii', 'replace')
11501150
ps_name = Name(ps_name)

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,10 +695,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
695695
self.set_color(*gc.get_rgb())
696696
sfnt = font.get_sfnt()
697697
try:
698-
ps_name = sfnt[(1,0,0,6)].decode('macroman')
698+
ps_name = sfnt[1, 0, 0, 6].decode('mac_roman')
699699
except KeyError:
700-
ps_name = sfnt[(3,1,0x0409,6)].decode(
701-
'utf-16be')
700+
ps_name = sfnt[3, 1, 0x0409, 6].decode('utf-16be')
702701
ps_name = ps_name.encode('ascii', 'replace').decode('ascii')
703702
self.set_font(ps_name, prop.get_size_in_points())
704703

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def _write_svgfonts(self):
505505
font = get_font(font_fname)
506506
font.set_size(72, 72)
507507
sfnt = font.get_sfnt()
508-
writer.start('font', id=sfnt[(1, 0, 0, 4)])
508+
writer.start('font', id=sfnt[1, 0, 0, 4].decode("mac_roman"))
509509
writer.element(
510510
'font-face',
511511
attrib={

lib/matplotlib/font_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,11 @@ def ttfFontProperty(font):
408408
sfnt2 = sfnt.get((1,0,0,2))
409409
sfnt4 = sfnt.get((1,0,0,4))
410410
if sfnt2:
411-
sfnt2 = sfnt2.decode('macroman').lower()
411+
sfnt2 = sfnt2.decode('mac_roman').lower()
412412
else:
413413
sfnt2 = ''
414414
if sfnt4:
415-
sfnt4 = sfnt4.decode('macroman').lower()
415+
sfnt4 = sfnt4.decode('mac_roman').lower()
416416
else:
417417
sfnt4 = ''
418418
if sfnt4.find('oblique') >= 0:

lib/matplotlib/textpath.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ def _get_char_id(self, font, ccode):
6767
"""
6868
sfnt = font.get_sfnt()
6969
try:
70-
ps_name = sfnt[(1, 0, 0, 6)].decode('macroman')
70+
ps_name = sfnt[1, 0, 0, 6].decode('mac_roman')
7171
except KeyError:
72-
ps_name = sfnt[(3, 1, 0x0409, 6)].decode('utf-16be')
72+
ps_name = sfnt[3, 1, 0x0409, 6].decode('utf-16be')
7373
char_id = urllib_quote('%s-%x' % (ps_name, ccode))
7474
return char_id
7575

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