From: <jo...@us...> - 2007-09-04 20:27:39
|
Revision: 3779 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3779&view=rev Author: jouni Date: 2007-09-04 13:27:36 -0700 (Tue, 04 Sep 2007) Log Message: ----------- More work on supporting Type 1 fonts in PDF. Sort of works now. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/dviread.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-09-04 19:52:23 UTC (rev 3778) +++ trunk/matplotlib/CHANGELOG 2007-09-04 20:27:36 UTC (rev 3779) @@ -1,3 +1,7 @@ +2007-09-04 Embedding Type 1 fonts in PDF, and thus usetex support + via dviread, sort of works. To test, enable it by + renaming _draw_tex to draw_tex. - JKS + 2007-09-03 Added ability of errorbar show limits via caret or arrowhead ends on the bars; patch by Manual Metz. - EF Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-09-04 19:52:23 UTC (rev 3778) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-09-04 20:27:36 UTC (rev 3779) @@ -581,7 +581,7 @@ 'CapHeight': 1000, # default guess if missing from AFM file 'XHeight': afmdata.get_xheight(), 'FontFile': fontfileObject, - 'FontFamily': Name(familyname), + 'FontFamily': familyname, #'FontWeight': a number where 400 = Regular, 700 = Bold } try: @@ -1422,7 +1422,7 @@ self.file.output(Op.grestore) def _draw_tex(self, gc, x, y, s, prop, angle): - # Rename to draw_tex to enable, but it doesn't work at the moment + # Rename to draw_tex to enable texmanager = self.get_texmanager() fontsize = prop.get_size_in_points() @@ -1606,6 +1606,19 @@ return draw_text_woven(chunks) def get_text_width_height_descent(self, s, prop, ismath): + if rcParams['text.usetex']: + texmanager = self.get_texmanager() + fontsize = prop.get_size_in_points() + dvifile = texmanager.make_dvi(s, fontsize) + dvi = dviread.Dvi(dvifile, 72) + text, boxes = iter(dvi).next() + # TODO: better bounding box -- this is not quite right: + l = min(p[0] for p in text+boxes) + r = max(p[0] for p in text+boxes) + fontsize + b = min(p[1] for p in text+boxes) + t = max(p[1] for p in text+boxes) + fontsize + # (not to even mention finding the baseline) + return r-l, t-b, t-b if ismath: w, h, d, glyphs, rects, used_characters = \ self.mathtext_parser.parse(s, 72, prop) Modified: trunk/matplotlib/lib/matplotlib/dviread.py =================================================================== --- trunk/matplotlib/lib/matplotlib/dviread.py 2007-09-04 19:52:23 UTC (rev 3778) +++ trunk/matplotlib/lib/matplotlib/dviread.py 2007-09-04 20:27:36 UTC (rev 3779) @@ -15,6 +15,8 @@ ... """ +# TODO: support for TeX virtual fonts (*.vf) which are a dvi-like format + import matplotlib import matplotlib.cbook as mpl_cbook import os This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |