Revision: 7283
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7283&view=rev
Author: evilguru
Date: 2009-07-22 13:47:42 +0000 (Wed, 22 Jul 2009)
Log Message:
-----------
Port the OS X backend over. I am unable to test this at the current time.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_macosx.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_macosx.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_macosx.py 2009-07-22
13:08:41 UTC (rev 7282)
+++ branches/mathtex/lib/matplotlib/backends/backend_macosx.py 2009-07-22
13:47:42 UTC (rev 7283)
@@ -9,11 +9,11 @@
from matplotlib.cbook import maxdict
from matplotlib.figure import Figure
from matplotlib.path import Path
-from matplotlib.mathtext import MathTextParser
from matplotlib.colors import colorConverter
+from mathtex.mathtex_main import Mathtex
+from mathtex.backends.backend_image import MathtexBackendImage
-
from matplotlib.widgets import SubplotTool
import matplotlib
@@ -77,7 +77,7 @@
nrows, ncols, data = im.as_rgba_str()
self.gc.draw_image(x, y, nrows, ncols, data, bbox, clippath,
clippath_trans)
im.flipud_out()
-
+
def draw_tex(self, gc, x, y, s, prop, angle):
# todo, handle props, angle, origins
size = prop.get_size_in_points()
@@ -91,10 +91,12 @@
gc.draw_mathtext(x, y, angle, Z)
def _draw_mathtext(self, gc, x, y, s, prop, angle):
- ox, oy, width, height, descent, image, used_characters = \
- self.mathtext_parser.parse(s, self.dpi, prop)
- gc.draw_mathtext(x, y, angle, 255 - image.as_array())
+ m = Mathtex(s, rcParams['mathtext.fontset'],
prop.get_size_in_points(), self.dpi)
+ b = MathtexBackendImage()
+ m.render_to_backend(b)
+ gc.draw_mathtext(x, y, angle, 255 - b.image.as_array())
+
def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
if ismath:
self._draw_mathtext(gc, x, y, s, prop, angle)
@@ -115,9 +117,9 @@
renderer=self)
return w, h, d
if ismath:
- ox, oy, width, height, descent, fonts, used_characters = \
- self.mathtext_parser.parse(s, self.dpi, prop)
- return width, height, descent
+ m = Mathtex(s, rcParams['mathtext.fontset'],
+ prop.get_size_in_points(), self.dpi)
+ return m.width, m.height, m.depth
family = prop.get_family()
weight = prop.get_weight()
style = prop.get_style()
@@ -128,7 +130,7 @@
def flipy(self):
return False
-
+
def points_to_pixels(self, points):
return points/72.0 * self.dpi
@@ -168,7 +170,7 @@
_macosx.GraphicsContext.set_clip_path(self, path)
########################################################################
-#
+#
# The following functions and classes are for pylab and implement
# window/figure managers, etc...
#
@@ -281,7 +283,7 @@
self.toolbar = NavigationToolbar2Mac(canvas)
else:
self.toolbar = None
- if self.toolbar is not None:
+ if self.toolbar is not None:
self.toolbar.update()
def notify_axes_change(fig):
@@ -300,7 +302,7 @@
Gcf.destroy(self.num)
class NavigationToolbarMac(_macosx.NavigationToolbar):
-
+
def __init__(self, canvas):
self.canvas = canvas
basedir = os.path.join(matplotlib.rcParams['datapath'], "images")
@@ -331,7 +333,7 @@
assert magic=="P6"
assert len(imagedata)==width*height*3 # 3 colors in RGB
return (width, height, imagedata)
-
+
def panx(self, direction):
axes = self.canvas.figure.axes
selected = self.get_active()
@@ -401,9 +403,9 @@
_macosx.NavigationToolbar2.set_message(self, message.encode('utf-8'))
########################################################################
-#
+#
# Now just provide the standard names that backend.__init__ is expecting
-#
+#
########################################################################
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins