@@ -491,7 +491,9 @@ def __init__(self, filename, metadata=None):
491491 self .infoDict = {k : v for (k , v ) in self .infoDict .items ()
492492 if v is not None }
493493
494- self .fontNames = {} # maps filenames to internal font names
494+ # fontNames maps filenames/dvi names to internal font names;
495+ # dvi font names have an entry in dviFontInfo
496+ self .fontNames = {}
495497 self .nextFont = 1 # next free internal font name
496498 self .dviFontInfo = {} # information on dvi fonts
497499 # differently encoded Type-1 fonts may share the same descriptor
@@ -636,11 +638,11 @@ def endStream(self):
636638 def fontName (self , fontprop ):
637639 """
638640 Select a font based on fontprop and return a name suitable for
639- Op.selectfont. If fontprop is a string, it will be interpreted
640- as the filename ( or dvi name) of the font.
641+ Op.selectfont. If fontprop is a string or bytestring , it will
642+ be interpreted as the filename or dvi name of the font.
641643 """
642644
643- if is_string_like (fontprop ):
645+ if isinstance (fontprop , ( str , bytes ) ):
644646 filename = fontprop
645647 elif rcParams ['pdf.use14corefonts' ]:
646648 filename = findfont (
@@ -667,16 +669,16 @@ def writeFonts(self):
667669 for filename in sorted (self .fontNames ):
668670 Fx = self .fontNames [filename ]
669671 matplotlib .verbose .report ('Embedding font %s' % filename , 'debug' )
670- if filename .endswith ('.afm' ):
671- # from pdf.use14corefonts
672- matplotlib .verbose .report ('Writing AFM font' , 'debug' )
673- fonts [Fx ] = self ._write_afm_font (filename )
674- elif filename in self .dviFontInfo :
672+ if filename in self .dviFontInfo :
675673 # a Type 1 font from a dvi file;
676674 # the filename is really the TeX name
677675 matplotlib .verbose .report ('Writing Type-1 font' , 'debug' )
678676 fonts [Fx ] = self .embedTeXFont (filename ,
679677 self .dviFontInfo [filename ])
678+ elif filename .endswith ('.afm' ):
679+ # from pdf.use14corefonts
680+ matplotlib .verbose .report ('Writing AFM font' , 'debug' )
681+ fonts [Fx ] = self ._write_afm_font (filename )
680682 else :
681683 # a normal TrueType font
682684 matplotlib .verbose .report ('Writing TrueType font' , 'debug' )
@@ -699,8 +701,8 @@ def _write_afm_font(self, filename):
699701 return fontdictObject
700702
701703 def embedTeXFont (self , texname , fontinfo ):
702- msg = ('Embedding TeX font ' + texname + ' - fontinfo=' +
703- repr ( fontinfo .__dict__ ))
704+ msg = ('Embedding TeX font {0} - fontinfo={1}'
705+ . format ( texname , fontinfo .__dict__ ))
704706 matplotlib .verbose .report (msg , 'debug' )
705707
706708 # Widths
0 commit comments