@@ -515,21 +515,30 @@ def embedType1(self, filename, fontinfo):
515515 _ , _ , fullname , familyname , weight , italic_angle , fixed_pitch , \
516516 ul_position , ul_thickness = font .get_ps_font_info ()
517517
518- differencesArray = [ 0 ] + [ Name (ch ) for ch in
519- dviread .Encoding (fontinfo .encoding ) ]
518+ if fontinfo .encodingfile is not None :
519+ differencesArray = [ Name (ch ) for ch in
520+ dviread .Encoding (fontinfo .encodingfile ) ]
521+ differencesArray = [ 0 ] + differencesArray
522+ lastchar = len (differencesArray ) - 2
523+ else :
524+ lastchar = 255 # ?
520525
521526 fontdict = {
522527 'Type' : Name ('Font' ),
523528 'Subtype' : Name ('Type1' ),
524529 'BaseFont' : Name (font .postscript_name ),
525530 'FirstChar' : 0 ,
526- 'LastChar' : len ( differencesArray ) - 2 ,
531+ 'LastChar' : lastchar ,
527532 'Widths' : widthsObject ,
528533 'FontDescriptor' : fontdescObject ,
529- 'Encoding' : { 'Type' : Name ('Encoding' ),
530- 'Differences' : differencesArray },
531534 }
532535
536+ if fontinfo .encodingfile is not None :
537+ fontdict .update ({
538+ 'Encoding' : { 'Type' : Name ('Encoding' ),
539+ 'Differences' : differencesArray },
540+ })
541+
533542 flags = 0
534543 if fixed_pitch : flags |= 1 << 0 # fixed width
535544 if 0 : flags |= 1 << 1 # TODO: serif
@@ -570,11 +579,11 @@ def embedType1(self, filename, fontinfo):
570579 descriptor ['StemH' ] = StemH
571580
572581 self .writeObject (fontdictObject , fontdict )
573- self .writeObject (widthsObject , widths )
582+ self .writeObject (widthsObject , [ 100 for i in range ( 256 )]) # XXX TODO
574583 self .writeObject (fontdescObject , descriptor )
575584
576585 fontdata = type1font .Type1Font (filename )
577- len1 , len2 , len3 = fontdata .lenghts ()
586+ len1 , len2 , len3 = fontdata .lengths ()
578587 self .beginStream (fontfileObject .id , None ,
579588 { 'Length1' : len1 ,
580589 'Length2' : len2 ,
@@ -1386,14 +1395,8 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
13861395 self .file .output (Op .grestore )
13871396
13881397 def _draw_tex (self , gc , x , y , s , prop , angle ):
1389- # Rename to draw_tex to enable, but note the following:
1390- # TODO:
1391- # - font sizes other than 10pt
1392- # - fonts other than the three ttf files included with matplotlib
1393- # (will need to support Type-1 fonts and find them with kpsewhich)
1394- # - encoding issues (e.g. \alpha doesn't work now)
1395- # - overall robustness
1396- # - ...
1398+ # Rename to draw_tex to enable, but it doesn't work at the moment
1399+
13971400 texmanager = self .get_texmanager ()
13981401 fontsize = prop .get_size_in_points ()
13991402 dvifile = texmanager .make_dvi (s , fontsize )
0 commit comments