Revision: 7269
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7269&view=rev
Author: evilguru
Date: 2009-07-17 20:03:21 +0000 (Fri, 17 Jul 2009)
Log Message:
-----------
Add the PDF backend to the mathtex family. Resistance is futile.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_pdf.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_pdf.py 2009-07-17
19:03:07 UTC (rev 7268)
+++ branches/mathtex/lib/matplotlib/backends/backend_pdf.py 2009-07-17
20:03:21 UTC (rev 7269)
@@ -38,11 +38,12 @@
import matplotlib.dviread as dviread
from matplotlib.ft2font import FT2Font, FIXED_WIDTH, ITALIC, LOAD_NO_SCALE, \
LOAD_NO_HINTING, KERNING_UNFITTED
-from matplotlib.mathtext import MathTextParser
from matplotlib.transforms import Affine2D, Bbox, BboxBase, TransformedPath
from matplotlib.path import Path
from matplotlib import ttconv
+from mathtex.mathtex_main import Mathtex
+
# Overview
#
# The low-level knowledge about pdf syntax lies mainly in the pdfRepr
@@ -1242,7 +1243,6 @@
RendererBase.__init__(self)
self.file = file
self.gc = self.new_gc()
- self.mathtext_parser = MathTextParser("Pdf")
self.image_dpi = image_dpi
self.tex_font_map = None
@@ -1344,10 +1344,23 @@
def draw_mathtext(self, gc, x, y, s, prop, angle):
# TODO: fix positioning and encoding
- width, height, descent, glyphs, rects, used_characters = \
- self.mathtext_parser.parse(s, 72, prop)
+ m = Mathtex(s, rcParams['mathtext.fontset'],
prop.get_size_in_points(), 72.0)
+
+ # Generate the dict of used characters
+ used_characters = {}
+ for ox, oy, info in m.glyphs:
+ realpath, stat_key = get_realpath_and_stat(info.font.fname)
+ used_font = used_characters.setdefault(stat_key, (realpath, set()))
+ used_font[1].add(info.num)
+
self.merge_used_characters(used_characters)
+ # Extract the glyphs and rects to render
+ glyphs = [(ox, m.height - oy + info.offset, info.font.fname,
+ info.fontsize, info.num, info.symbol_name)
+ for ox, oy, info in m.glyphs]
+ rects = [(x1, m.height - y2, x2 - x1, y2 - y1) for x1, y1, x2, y2 in
m.rects]
+
# When using Type 3 fonts, we can't use character codes higher
# than 255, so we use the "Do" command to render those
# instead.
@@ -1641,8 +1654,9 @@
return w, h, d
if ismath:
- w, h, d, glyphs, rects, used_characters = \
- self.mathtext_parser.parse(s, 72, prop)
+ m = Mathtex(s, rcParams['mathtext.fontset'],
+ prop.get_size_in_points(), 72.0)
+ w, h, d = m.width, m.height, m.depth
elif rcParams['pdf.use14corefonts']:
font = self._get_font_afm(prop)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins