2018-05-21 17:47:46 +00:00
|
|
|
diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py
|
|
|
|
index 4f248fde9..0fc17ea37 100644
|
|
|
|
--- a/lib/matplotlib/backends/backend_pdf.py
|
|
|
|
+++ b/lib/matplotlib/backends/backend_pdf.py
|
|
|
|
@@ -1135,15 +1135,7 @@ end"""
|
|
|
|
|
|
|
|
# Beginning of main embedTTF function...
|
|
|
|
|
|
|
|
- # You are lost in a maze of TrueType tables, all different...
|
|
|
|
- sfnt = font.get_sfnt()
|
|
|
|
- try:
|
|
|
|
- ps_name = sfnt[1, 0, 0, 6].decode('mac_roman') # Macintosh scheme
|
|
|
|
- except KeyError:
|
|
|
|
- # Microsoft scheme:
|
|
|
|
- ps_name = sfnt[3, 1, 0x0409, 6].decode('utf-16be')
|
|
|
|
- # (see freetype/ttnameid.h)
|
|
|
|
- ps_name = ps_name.encode('ascii', 'replace')
|
|
|
|
+ ps_name = font.postscript_name.encode('ascii', 'replace')
|
|
|
|
ps_name = Name(ps_name)
|
|
|
|
pclt = font.get_sfnt_table('pclt') or {'capHeight': 0, 'xHeight': 0}
|
|
|
|
post = font.get_sfnt_table('post') or {'italicAngle': (0, 0)}
|
|
|
|
diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py
|
|
|
|
index 1aeee39a2..3d44b6f7f 100644
|
|
|
|
--- a/lib/matplotlib/backends/backend_ps.py
|
|
|
|
+++ b/lib/matplotlib/backends/backend_ps.py
|
|
|
|
@@ -714,12 +714,8 @@ grestore
|
|
|
|
self.track_characters(font, s)
|
|
|
|
|
|
|
|
self.set_color(*gc.get_rgb())
|
|
|
|
- sfnt = font.get_sfnt()
|
|
|
|
- try:
|
|
|
|
- ps_name = sfnt[1, 0, 0, 6].decode('mac_roman')
|
|
|
|
- except KeyError:
|
|
|
|
- ps_name = sfnt[3, 1, 0x0409, 6].decode('utf-16be')
|
|
|
|
- ps_name = ps_name.encode('ascii', 'replace').decode('ascii')
|
|
|
|
+ ps_name = (font.postscript_name
|
|
|
|
+ .encode('ascii', 'replace').decode('ascii'))
|
|
|
|
self.set_font(ps_name, prop.get_size_in_points())
|
|
|
|
|
|
|
|
lastgind = None
|
|
|
|
diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py
|
|
|
|
index cdc82edbf..2ea6efc2d 100644
|
|
|
|
--- a/lib/matplotlib/font_manager.py
|
|
|
|
+++ b/lib/matplotlib/font_manager.py
|
|
|
|
@@ -413,16 +413,11 @@ def ttfFontProperty(font):
|
|
|
|
# Styles are: italic, oblique, and normal (default)
|
|
|
|
|
|
|
|
sfnt = font.get_sfnt()
|
|
|
|
- sfnt2 = sfnt.get((1,0,0,2))
|
|
|
|
- sfnt4 = sfnt.get((1,0,0,4))
|
|
|
|
- if sfnt2:
|
2018-05-17 15:57:39 +00:00
|
|
|
- sfnt2 = sfnt2.decode('mac_roman').lower()
|
2018-05-21 17:47:46 +00:00
|
|
|
- else:
|
|
|
|
- sfnt2 = ''
|
|
|
|
- if sfnt4:
|
2018-05-17 15:57:39 +00:00
|
|
|
- sfnt4 = sfnt4.decode('mac_roman').lower()
|
2018-05-21 17:47:46 +00:00
|
|
|
- else:
|
|
|
|
- sfnt4 = ''
|
|
|
|
+ # These tables are actually mac_roman-encoded, but mac_roman support may be
|
|
|
|
+ # missing in some alternative Python implementations and we are only going
|
|
|
|
+ # to look for ASCII substrings, where any ASCII-compatible encoding works.
|
|
|
|
+ sfnt2 = sfnt.get((1, 0, 0, 2), b'').decode('latin-1').lower()
|
|
|
|
+ sfnt4 = sfnt.get((1, 0, 0, 4), b'').decode('latin-1').lower()
|
|
|
|
if sfnt4.find('oblique') >= 0:
|
|
|
|
style = 'oblique'
|
|
|
|
elif sfnt4.find('italic') >= 0:
|
|
|
|
diff --git a/lib/matplotlib/textpath.py b/lib/matplotlib/textpath.py
|
|
|
|
index 5ee356774..89fcfb79c 100644
|
|
|
|
--- a/lib/matplotlib/textpath.py
|
|
|
|
+++ b/lib/matplotlib/textpath.py
|
|
|
|
@@ -68,13 +68,7 @@ class TextToPath(object):
|
|
|
|
"""
|
|
|
|
Return a unique id for the given font and character-code set.
|
|
|
|
"""
|
|
|
|
- sfnt = font.get_sfnt()
|
|
|
|
- try:
|
|
|
|
- ps_name = sfnt[1, 0, 0, 6].decode('mac_roman')
|
|
|
|
- except KeyError:
|
|
|
|
- ps_name = sfnt[3, 1, 0x0409, 6].decode('utf-16be')
|
|
|
|
- char_id = urllib_quote('%s-%x' % (ps_name, ccode))
|
|
|
|
- return char_id
|
|
|
|
+ return urllib_quote('%s-%x' % (font.postscript_name, ccode))
|
|
|
|
|
|
|
|
def _get_char_id_ps(self, font, ccode):
|
|
|
|
"""
|