Revision: 7636
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7636&view=rev
Author:   leejjoon
Date:     2009-09-04 20:20:06 +0000 (Fri, 04 Sep 2009)

Log Message:
-----------
textpath.py: import texmanager only when required

Modified Paths:
--------------
    trunk/matplotlib/examples/pylab_examples/demo_text_path.py
    trunk/matplotlib/lib/matplotlib/textpath.py

Modified: trunk/matplotlib/examples/pylab_examples/demo_text_path.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/demo_text_path.py  2009-09-04 
19:11:00 UTC (rev 7635)
+++ trunk/matplotlib/examples/pylab_examples/demo_text_path.py  2009-09-04 
20:20:06 UTC (rev 7636)
@@ -54,6 +54,8 @@
 
 if 1:
 
+    usetex = plt.rcParams["text.usetex"]
+    
     fig = plt.figure(1)
 
     # EXAMPLE 1
@@ -80,8 +82,14 @@
 
     # another text
     from matplotlib.patches import PathPatch
-    text_path = TextPath((0, 0), r"\mbox{textpath supports mathtext \& \TeX}",
-                         size=20, usetex=True)
+    if usetex:
+        r = r"\mbox{textpath supports mathtext \& \TeX}"
+    else:
+        r = r"textpath supports mathtext & TeX"
+        
+    text_path = TextPath((0, 0), r,
+                         size=20, usetex=usetex)
+        
     p1 = PathPatch(text_path, ec="w", lw=3, fc="w", alpha=0.9,
                    transform=IdentityTransform())
     p2 = PathPatch(text_path, ec="none", fc="k", 
@@ -111,7 +119,6 @@
 
     arr = np.arange(256).reshape(1,256)/256.
 
-    usetex = plt.rcParams["text.usetex"]
     if usetex:
         s = 
r"$\displaystyle\left[\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}\right]$!"
     else:

Modified: trunk/matplotlib/lib/matplotlib/textpath.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/textpath.py 2009-09-04 19:11:00 UTC (rev 
7635)
+++ trunk/matplotlib/lib/matplotlib/textpath.py 2009-09-04 20:20:06 UTC (rev 
7636)
@@ -9,7 +9,6 @@
 from matplotlib.mathtext import MathTextParser
 
 import matplotlib.dviread as dviread
-from matplotlib.texmanager import TexManager
 
 import numpy as np
 
@@ -31,6 +30,7 @@
         from matplotlib.cbook import maxdict
         self._ps_fontd = maxdict(50)
 
+        self._texmanager = None
 
     def _get_font(self, prop):
         """
@@ -243,7 +243,16 @@
         return zip(glyph_ids, xpositions, ypositions, sizes), glyph_map, 
myrects
 
 
+    def get_texmanager(self):
+        """
+        return the :class:`matplotlib.texmanager.TexManager` instance
+        """
+        if self._texmanager is None:
+            from matplotlib.texmanager import TexManager
+            self._texmanager = TexManager()
+        return self._texmanager
 
+
     def get_glyphs_tex(self, prop, s):
         """
         convert the string *s* to vertices and codes using matplotlib's usetex 
mode.
@@ -251,7 +260,7 @@
 
         # codes are modstly borrowed from pdf backend.
         
-        texmanager = TexManager()
+        texmanager = self.get_texmanager()
 
         if self.tex_font_map is None:
             self.tex_font_map = 
dviread.PsfontsMap(dviread.find_tex_file('pdftex.map'))


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to