From: <md...@us...> - 2010-10-22 16:20:21
|
Revision: 8761 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8761&view=rev Author: mdboom Date: 2010-10-22 16:20:15 +0000 (Fri, 22 Oct 2010) Log Message: ----------- Merged revisions 8760 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v1_0_maint ........ r8760 | mdboom | 2010-10-22 12:17:26 -0400 (Fri, 22 Oct 2010) | 2 lines Fix problems with funnily encoded fonts in PS backend. ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/ttconv/pprdrv_tt.cpp Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /branches/v1_0_maint:1-8758 /trunk/matplotlib:1-7315 + /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /branches/v1_0_maint:1-8760 /trunk/matplotlib:1-7315 Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2010-10-22 16:17:26 UTC (rev 8760) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2010-10-22 16:20:15 UTC (rev 8761) @@ -610,8 +610,6 @@ draw a Text instance """ # local to avoid repeated attribute lookups - - write = self._pswriter.write if debugPS: write("% text\n") @@ -622,71 +620,9 @@ elif ismath: return self.draw_mathtext(gc, x, y, s, prop, angle) - elif isinstance(s, unicode): - return self.draw_unicode(gc, x, y, s, prop, angle) - elif rcParams['ps.useafm']: - font = self._get_font_afm(prop) - - l,b,w,h = font.get_str_bbox(s) - - fontsize = prop.get_size_in_points() - l *= 0.001*fontsize - b *= 0.001*fontsize - w *= 0.001*fontsize - h *= 0.001*fontsize - - if angle==90: l,b = -b, l # todo generalize for arb rotations - - pos = _nums_to_str(x-l, y-b) - thetext = '(%s)' % s - fontname = font.get_fontname() - fontsize = prop.get_size_in_points() - rotate = '%1.1f rotate' % angle - setcolor = '%1.3f %1.3f %1.3f setrgbcolor' % gc.get_rgb()[:3] - #h = 0 - ps = """\ -gsave -/%(fontname)s findfont -%(fontsize)s scalefont -setfont -%(pos)s moveto -%(rotate)s -%(thetext)s -%(setcolor)s -show -grestore - """ % locals() - self._draw_ps(ps, gc, None) - - else: - font = self._get_font_ttf(prop) - font.set_text(s, 0, flags=LOAD_NO_HINTING) - self.track_characters(font, s) - self.set_color(*gc.get_rgb()) - self.set_font(font.get_sfnt()[(1,0,0,6)], prop.get_size_in_points()) - write("%s m\n"%_nums_to_str(x,y)) - if angle: - write("gsave\n") - write("%s rotate\n"%_num_to_str(angle)) - descent = font.get_descent() / 64.0 - if descent: - write("0 %s rmoveto\n"%_num_to_str(descent)) - write("(%s) show\n"%quote_ps_string(s)) - if angle: - write("grestore\n") - def new_gc(self): - return GraphicsContextPS() - - def draw_unicode(self, gc, x, y, s, prop, angle): - """draw a unicode string. ps doesn't have unicode support, so - we have to do this the hard way - """ - if rcParams['ps.useafm']: - self.set_color(*gc.get_rgb()) - font = self._get_font_afm(prop) fontname = font.get_fontname() fontsize = prop.get_size_in_points() @@ -772,6 +708,9 @@ """ % locals() self._pswriter.write(ps) + def new_gc(self): + return GraphicsContextPS() + def draw_mathtext(self, gc, x, y, s, prop, angle): """ @@ -1125,7 +1064,6 @@ if is_opentype_cff_font(font_filename): raise RuntimeError("OpenType CFF fonts can not be saved using the internal Postscript backend at this time.\nConsider using the Cairo backend.") else: - fonttype = rcParams['ps.fonttype'] convert_ttf_to_ps(font_filename, fh, fonttype, glyph_ids) print >>fh, "end" print >>fh, "%%EndProlog" Modified: trunk/matplotlib/ttconv/pprdrv_tt.cpp =================================================================== --- trunk/matplotlib/ttconv/pprdrv_tt.cpp 2010-10-22 16:17:26 UTC (rev 8760) +++ trunk/matplotlib/ttconv/pprdrv_tt.cpp 2010-10-22 16:20:15 UTC (rev 8761) @@ -420,21 +420,19 @@ -------------------------------------------------------------*/ void ttfont_encoding(TTStreamWriter& stream, struct TTFONT *font, std::vector<int>& glyph_ids, font_type_enum target_type) { - stream.putline("/Encoding StandardEncoding def"); + if (target_type == PS_TYPE_3) { + stream.printf("/Encoding [ "); - // if (target_type == PS_TYPE_3) { - // stream.printf("/Encoding [ "); + for (std::vector<int>::const_iterator i = glyph_ids.begin(); + i != glyph_ids.end(); ++i) { + const char* name = ttfont_CharStrings_getname(font, *i); + stream.printf("/%s ", name); + } - // for (std::vector<int>::const_iterator i = glyph_ids.begin(); - // i != glyph_ids.end(); ++i) { - // const char* name = ttfont_CharStrings_getname(font, *i); - // stream.printf("/%s ", name); - // } - - // stream.printf("] def\n"); - // } else { - // stream.putline("/Encoding StandardEncoding def"); - // } + stream.printf("] def\n"); + } else { + stream.putline("/Encoding StandardEncoding def"); + } } /* end of ttfont_encoding() */ /*----------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |