@@ -610,8 +610,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
610
610
draw a Text instance
611
611
"""
612
612
# local to avoid repeated attribute lookups
613
-
614
-
615
613
write = self ._pswriter .write
616
614
if debugPS :
617
615
write ("% text\n " )
@@ -622,69 +620,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
622
620
elif ismath :
623
621
return self .draw_mathtext (gc , x , y , s , prop , angle )
624
622
625
- elif isinstance (s , unicode ):
626
- return self .draw_unicode (gc , x , y , s , prop , angle )
627
-
628
623
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' ]:
688
624
self .set_color (* gc .get_rgb ())
689
625
690
626
font = self ._get_font_afm (prop )
@@ -772,6 +708,9 @@ def draw_unicode(self, gc, x, y, s, prop, angle):
772
708
""" % locals ()
773
709
self ._pswriter .write (ps )
774
710
711
+ def new_gc (self ):
712
+ return GraphicsContextPS ()
713
+
775
714
def draw_mathtext (self , gc ,
776
715
x , y , s , prop , angle ):
777
716
"""
@@ -1125,7 +1064,6 @@ def write(self, *kl, **kwargs):
1125
1064
if is_opentype_cff_font (font_filename ):
1126
1065
raise RuntimeError ("OpenType CFF fonts can not be saved using the internal Postscript backend at this time.\n Consider using the Cairo backend." )
1127
1066
else :
1128
- fonttype = rcParams ['ps.fonttype' ]
1129
1067
convert_ttf_to_ps (font_filename , fh , fonttype , glyph_ids )
1130
1068
print >> fh , "end"
1131
1069
print >> fh , "%%EndProlog"
0 commit comments