Revision: 7712
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7712&view=rev
Author: mdboom
Date: 2009-09-08 15:17:20 +0000 (Tue, 08 Sep 2009)
Log Message:
-----------
Add an rcParam for hinting, and set it to False when running tests.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/__init__.py
trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
trunk/matplotlib/lib/matplotlib/config/mplconfig.py
trunk/matplotlib/lib/matplotlib/config/rcsetup.py
trunk/matplotlib/lib/matplotlib/mathtext.py
trunk/matplotlib/lib/matplotlib/rcsetup.py
trunk/matplotlib/lib/matplotlib/text.py
trunk/matplotlib/matplotlibrc.template
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2009-09-08 15:13:33 UTC (rev
7711)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2009-09-08 15:17:20 UTC (rev
7712)
@@ -893,6 +893,8 @@
from testing.noseclasses import KnownFailure
from nose.plugins.manager import PluginManager
use('Agg') # use Agg backend for these tests
+ rcParams['font.family'] = 'Bitstream Vera Sans'
+ rcParams['text.hinting'] = False
plugins = []
plugins.append( KnownFailure() )
plugins.extend( [plugin() for plugin in nose.plugins.builtin.plugins] )
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2009-09-08
15:13:33 UTC (rev 7711)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2009-09-08
15:17:20 UTC (rev 7712)
@@ -30,7 +30,7 @@
from matplotlib.cbook import is_string_like, maxdict
from matplotlib.figure import Figure
from matplotlib.font_manager import findfont
-from matplotlib.ft2font import FT2Font, LOAD_FORCE_AUTOHINT
+from matplotlib.ft2font import FT2Font, LOAD_FORCE_AUTOHINT, LOAD_NO_HINTING
from matplotlib.mathtext import MathTextParser
from matplotlib.path import Path
from matplotlib.transforms import Bbox, BboxBase
@@ -69,6 +69,12 @@
if __debug__: verbose.report('RendererAgg.__init__ done',
'debug-annoying')
+ def _get_hinting_flag(self):
+ if rcParams['text.hinting']:
+ return LOAD_FORCE_AUTOHINT
+ else:
+ return LOAD_NO_HINTING
+
def draw_markers(self, *kl, **kw):
# for filtering to work with rastrization, methods needs to be wrapped.
# maybe there is better way to do it.
@@ -132,14 +138,15 @@
if ismath:
return self.draw_mathtext(gc, x, y, s, prop, angle)
+ flags = self._get_hinting_flag()
font = self._get_agg_font(prop)
if font is None: return None
if len(s) == 1 and ord(s) > 127:
- font.load_char(ord(s), flags=LOAD_FORCE_AUTOHINT)
+ font.load_char(ord(s), flags=flags)
else:
# We pass '0' for angle here, since it will be rotated (in raster
# space) in the following call to draw_text_image).
- font.set_text(s, 0, flags=LOAD_FORCE_AUTOHINT)
+ font.set_text(s, 0, flags=flags)
font.draw_glyphs_to_bitmap()
#print x, y, int(x), int(y), s
@@ -168,8 +175,10 @@
ox, oy, width, height, descent, fonts, used_characters = \
self.mathtext_parser.parse(s, self.dpi, prop)
return width, height, descent
+
+ flags = self._get_hinting_flag()
font = self._get_agg_font(prop)
- font.set_text(s, 0.0, flags=LOAD_FORCE_AUTOHINT) # the width and
height of unrotated string
+ font.set_text(s, 0.0, flags=flags) # the width and height of
unrotated string
w, h = font.get_width_height()
d = font.get_descent()
w /= 64.0 # convert from subpixels
Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2009-09-08 15:13:33 UTC
(rev 7711)
+++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2009-09-08 15:17:20 UTC
(rev 7712)
@@ -154,6 +154,7 @@
class text(TConfig):
color = T.Trait('black',mplT.ColorHandler())
usetex = T.false
+ hinting = T.true
class latex(TConfig):
unicode = T.false
@@ -338,6 +339,7 @@
'text.latex.unicode' : (self.tconfig.text.latex, 'unicode'),
'text.latex.preamble' : (self.tconfig.text.latex, 'preamble'),
'text.dvipnghack' : (self.tconfig.text.latex, 'dvipnghack'),
+ 'text.hinting' : (self.tconfig.text, 'hinting'),
'mathtext.cal' : (self.tconfig.mathtext, 'cal'),
'mathtext.rm' : (self.tconfig.mathtext, 'rm'),
Modified: trunk/matplotlib/lib/matplotlib/config/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2009-09-08 15:13:33 UTC
(rev 7711)
+++ trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2009-09-08 15:17:20 UTC
(rev 7712)
@@ -361,6 +361,7 @@
'text.fontvariant' : ['normal', str],
'text.fontweight' : ['normal', str],
'text.fontsize' : ['medium', validate_fontsize],
+ 'text.hinting' : [True, validate_bool],
'mathtext.cal' : ['cursive', validate_font_properties],
'mathtext.rm' : ['serif', validate_font_properties],
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py 2009-09-08 15:13:33 UTC (rev
7711)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py 2009-09-08 15:17:20 UTC (rev
7712)
@@ -222,7 +222,10 @@
self.fonts_object.get_used_characters())
def get_hinting_type(self):
- return LOAD_FORCE_AUTOHINT
+ if rcParams['text.hinting']:
+ return LOAD_FORCE_AUTOHINT
+ else:
+ return LOAD_NO_HINTING
def MathtextBackendAgg():
return MathtextBackendBbox(MathtextBackendAggRender())
Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/rcsetup.py 2009-09-08 15:13:33 UTC (rev
7711)
+++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2009-09-08 15:17:20 UTC (rev
7712)
@@ -404,6 +404,7 @@
'text.fontvariant' : ['normal', str],
'text.fontweight' : ['normal', str],
'text.fontsize' : ['medium', validate_fontsize],
+ 'text.hinting' : [True, validate_bool],
'mathtext.cal' : ['cursive', validate_font_properties],
'mathtext.rm' : ['serif', validate_font_properties],
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py 2009-09-08 15:13:33 UTC (rev
7711)
+++ trunk/matplotlib/lib/matplotlib/text.py 2009-09-08 15:17:20 UTC (rev
7712)
@@ -25,7 +25,7 @@
from matplotlib.path import Path
import matplotlib.font_manager as font_manager
-from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING
+from matplotlib.ft2font import FT2Font
def _process_text_args(override, fontdict=None, **kwargs):
Modified: trunk/matplotlib/matplotlibrc.template
===================================================================
--- trunk/matplotlib/matplotlibrc.template 2009-09-08 15:13:33 UTC (rev
7711)
+++ trunk/matplotlib/matplotlibrc.template 2009-09-08 15:17:20 UTC (rev
7712)
@@ -167,6 +167,9 @@
# In that case, all text will be sent to TeX for
# processing.
+#text.hinting : True # If True, text will be hinted, otherwise not. This only
+ # affects the Agg backend.
+
# The following settings allow you to select the fonts in math mode.
# They map from a TeX font name to a fontconfig font pattern.
# These settings are only used if mathtext.fontset is 'custom'.
@@ -290,7 +293,7 @@
# A value of 20000 is probably a good
# starting point.
### SAVING FIGURES
-#path.simplify : False # When True, simplify paths by removing "invisible"
+#path.simplify : False # When True, simplify paths by removing "invisible"
# points to reduce file size and increase rendering
# speed
#path.simplify_threshold : 0.1 # The threshold of similarity below which
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