Revision: 5329
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5329&view=rev
Author:   jdh2358
Date:     2008-05-30 12:21:56 -0700 (Fri, 30 May 2008)

Log Message:
-----------
added support for None for dvipng and removed the sqrt in the hack which I 
think is wrong

Modified Paths:
--------------
    branches/v0_91_maint/lib/matplotlib/rcsetup.py
    branches/v0_91_maint/lib/matplotlib/texmanager.py
    branches/v0_91_maint/matplotlibrc.template

Modified: branches/v0_91_maint/lib/matplotlib/rcsetup.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/rcsetup.py      2008-05-30 18:59:44 UTC 
(rev 5328)
+++ branches/v0_91_maint/lib/matplotlib/rcsetup.py      2008-05-30 19:21:56 UTC 
(rev 5329)
@@ -42,6 +42,16 @@
     else:
         raise ValueError('Could not convert "%s" to boolean' % b)
 
+def validate_bool_maybe_none(b):
+    'Convert b to a boolean or raise'
+    if type(b) is str:
+        b = b.lower()
+    if b=='none': return None
+    if b in ('t', 'y', 'yes', 'on', 'true', '1', 1, True): return True
+    elif b in ('f', 'n', 'no', 'off', 'false', '0', 0, False): return False
+    else:
+        raise ValueError('Could not convert "%s" to boolean' % b)
+
 def validate_float(s):
     'convert s to float or raise'
     try: return float(s)
@@ -339,7 +349,7 @@
     'text.usetex'         : [False, validate_bool],
     'text.latex.unicode'  : [False, validate_bool],
     'text.latex.preamble' : [[''], validate_stringlist],
-    'text.dvipnghack'     : [False, validate_bool],
+    'text.dvipnghack'     : [None, validate_bool_maybe_none],
     'text.fontstyle'      : ['normal', str],
     'text.fontangle'      : ['normal', str],
     'text.fontvariant'    : ['normal', str],

Modified: branches/v0_91_maint/lib/matplotlib/texmanager.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/texmanager.py   2008-05-30 18:59:44 UTC 
(rev 5328)
+++ branches/v0_91_maint/lib/matplotlib/texmanager.py   2008-05-30 19:21:56 UTC 
(rev 5329)
@@ -334,7 +334,12 @@
             pngfile = self.make_png(tex, fontsize, dpi)
             X = readpng(os.path.join(self.texcache, pngfile))
 
-            if self._dvipng_hack_alpha or rcParams['text.dvipnghack']:
+            if rcParams['text.dvipnghack'] is not None:
+                hack = rcParams['text.dvipnghack']
+            else:
+                hack = self._dvipng_hack_alpha
+            print 'using hack', hack
+            if hack:
                 # hack the alpha channel
                 # dvipng assumed a constant background, whereas we want to
                 # overlay these rasters with antialiasing over arbitrary
@@ -356,7 +361,9 @@
                 #
                 # Since the foreground is black (0) and the background is
                 # white (1) this reduces to red = 1-alpha or alpha = 1-red
-                alpha = npy.sqrt(1-X[:,:,0])
+                #alpha = npy.sqrt(1-X[:,:,0]) # should this be sqrt here?
+                alpha = 1-X[:,:,0]
+                
             else:
                 alpha = X[:,:,-1]
 

Modified: branches/v0_91_maint/matplotlibrc.template
===================================================================
--- branches/v0_91_maint/matplotlibrc.template  2008-05-30 18:59:44 UTC (rev 
5328)
+++ branches/v0_91_maint/matplotlibrc.template  2008-05-30 19:21:56 UTC (rev 
5329)
@@ -147,9 +147,14 @@
                             # beware of package collisions: color, geometry, 
graphicx,
                             # type1cm, textcomp. Adobe Postscript (PSSNFS) 
font packages
                             # may also be loaded, depending on your font 
settings
-#text.dvipnghack     : False  # some versions of dvipng don't handle
-                             # alpha channel properly.  Use True to correct 
and flush
-                             # ~/.matplotlib/tex.cache before testing
+
+#text.dvipnghack : None      # some versions of dvipng don't handle alpha
+                             # channel properly.  Use True to correct
+                             # and flush ~/.matplotlib/tex.cache
+                             # before testing and False to force
+                             # correction off.  None will try and
+                             # guess based on your dvipng version
+
 #text.markup         : 'plain'  # Affects how text, such as titles and labels, 
are
                                 # interpreted by default.
                                 # 'plain': As plain, unformatted text


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to