@@ -610,8 +610,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
610610 draw a Text instance
611611 """
612612 # local to avoid repeated attribute lookups
613-
614-
615613 write = self ._pswriter .write
616614 if debugPS :
617615 write ("% text\n " )
@@ -622,69 +620,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
622620 elif ismath :
623621 return self .draw_mathtext (gc , x , y , s , prop , angle )
624622
625- elif isinstance (s , unicode ):
626- return self .draw_unicode (gc , x , y , s , prop , angle )
627-
628623 elif rcParams ['ps.useafm' ]:
629- font = self ._get_font_afm (prop )
630-
631- l ,b ,w ,h = font .get_str_bbox (s )
632-
633- fontsize = prop .get_size_in_points ()
634- l *= 0.001 * fontsize
635- b *= 0.001 * fontsize
636- w *= 0.001 * fontsize
637- h *= 0.001 * fontsize
638-
639- if angle == 90 : l ,b = - b , l # todo generalize for arb rotations
640-
641- pos = _nums_to_str (x - l , y - b )
642- thetext = '(%s)' % s
643- fontname = font .get_fontname ()
644- fontsize = prop .get_size_in_points ()
645- rotate = '%1.1f rotate' % angle
646- setcolor = '%1.3f %1.3f %1.3f setrgbcolor' % gc .get_rgb ()[:3 ]
647- #h = 0
648- ps = """\
649- gsave
650- /%(fontname)s findfont
651- %(fontsize)s scalefont
652- setfont
653- %(pos)s moveto
654- %(rotate)s
655- %(thetext)s
656- %(setcolor)s
657- show
658- grestore
659- """ % locals ()
660- self ._draw_ps (ps , gc , None )
661-
662- else :
663- font = self ._get_font_ttf (prop )
664- font .set_text (s , 0 , flags = LOAD_NO_HINTING )
665- self .track_characters (font , s )
666-
667- self .set_color (* gc .get_rgb ())
668- self .set_font (font .get_sfnt ()[(1 ,0 ,0 ,6 )], prop .get_size_in_points ())
669- write ("%s m\n " % _nums_to_str (x ,y ))
670- if angle :
671- write ("gsave\n " )
672- write ("%s rotate\n " % _num_to_str (angle ))
673- descent = font .get_descent () / 64.0
674- if descent :
675- write ("0 %s rmoveto\n " % _num_to_str (descent ))
676- write ("(%s) show\n " % quote_ps_string (s ))
677- if angle :
678- write ("grestore\n " )
679-
680- def new_gc (self ):
681- return GraphicsContextPS ()
682-
683- def draw_unicode (self , gc , x , y , s , prop , angle ):
684- """draw a unicode string. ps doesn't have unicode support, so
685- we have to do this the hard way
686- """
687- if rcParams ['ps.useafm' ]:
688624 self .set_color (* gc .get_rgb ())
689625
690626 font = self ._get_font_afm (prop )
@@ -772,6 +708,9 @@ def draw_unicode(self, gc, x, y, s, prop, angle):
772708""" % locals ()
773709 self ._pswriter .write (ps )
774710
711+ def new_gc (self ):
712+ return GraphicsContextPS ()
713+
775714 def draw_mathtext (self , gc ,
776715 x , y , s , prop , angle ):
777716 """
@@ -1125,7 +1064,6 @@ def write(self, *kl, **kwargs):
11251064 if is_opentype_cff_font (font_filename ):
11261065 raise RuntimeError ("OpenType CFF fonts can not be saved using the internal Postscript backend at this time.\n Consider using the Cairo backend." )
11271066 else :
1128- fonttype = rcParams ['ps.fonttype' ]
11291067 convert_ttf_to_ps (font_filename , fh , fonttype , glyph_ids )
11301068 print >> fh , "end"
11311069 print >> fh , "%%EndProlog"
0 commit comments