Revision: 7267
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7267&view=rev
Author:   evilguru
Date:     2009-07-17 18:44:30 +0000 (Fri, 17 Jul 2009)

Log Message:
-----------
Port the GDK backend over to mathtex.

Modified Paths:
--------------
    branches/mathtex/lib/matplotlib/backends/backend_gdk.py

Modified: branches/mathtex/lib/matplotlib/backends/backend_gdk.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_gdk.py     2009-07-17 
15:24:27 UTC (rev 7266)
+++ branches/mathtex/lib/matplotlib/backends/backend_gdk.py     2009-07-17 
18:44:30 UTC (rev 7267)
@@ -24,10 +24,11 @@
      FigureManagerBase, FigureCanvasBase
 from matplotlib.cbook import is_string_like
 from matplotlib.figure import Figure
-from matplotlib.mathtext import MathTextParser
 from matplotlib.transforms import Affine2D
 from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
 
+from mathtex.mathtex_main import Mathtex
+from mathtex.backends.backend_image import MathtexBackendImage
 
 backend_version = "%d.%d.%d" % gtk.pygtk_version
 _debug = False
@@ -71,7 +72,6 @@
         self.gtkDA = gtkDA
         self.dpi   = dpi
         self._cmap = gtkDA.get_colormap()
-        self.mathtext_parser = MathTextParser("Agg")
 
     def set_pixmap (self, pixmap):
         self.gdkDrawable = pixmap
@@ -159,9 +159,14 @@
 
 
     def _draw_mathtext(self, gc, x, y, s, prop, angle):
-        ox, oy, width, height, descent, font_image, used_characters = \
-            self.mathtext_parser.parse(s, self.dpi, prop)
+        m = Mathtex(s, matplotlib.rcParams['mathtext.fontset'],
+                    prop.get_size_in_points(), self.dpi)
+        b = MathtexBackendImage()
+        m.render_to_backend(b)
 
+        width, height = m.width, m.height + m.depth
+        font_image = b.image
+
         if angle==90:
             width, height = height, width
             x -= width
@@ -300,9 +305,9 @@
 
     def get_text_width_height_descent(self, s, prop, ismath):
         if ismath:
-            ox, oy, width, height, descent, font_image, used_characters = \
-                self.mathtext_parser.parse(s, self.dpi, prop)
-            return width, height, descent
+            m = Mathtex(s, matplotlib.rcParams['mathtext.fontset'],
+                        prop.get_size_in_points(), self.dpi)
+            return m.width, m.height, m.depth
 
         layout, inkRect, logicalRect = self._get_pango_layout(s, prop)
         l, b, w, h = inkRect


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

Reply via email to