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

Skip to content

Commit 000bb8b

Browse files
committed
Fix KeyError: (1, 0, 0, 6) in backend_ps on Windows
Using code from backend_pdf: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_pdf.py#L1002
1 parent b43d5f5 commit 000bb8b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,13 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
748748
self.track_characters(font, s)
749749

750750
self.set_color(*gc.get_rgb())
751-
self.set_font(font.get_sfnt()[(1,0,0,6)], prop.get_size_in_points())
751+
sfnt = font.get_sfnt()
752+
try:
753+
ps_name = sfnt[(1,0,0,6)]
754+
except KeyError:
755+
ps_name = sfnt[(3,1,0x0409,6)].decode(
756+
'utf-16be').encode('ascii','replace')
757+
self.set_font(ps_name, prop.get_size_in_points())
752758

753759
cmap = font.get_charmap()
754760
lastgind = None

0 commit comments

Comments
 (0)