From: <md...@us...> - 2008-12-26 16:28:07
|
Revision: 6702 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6702&view=rev Author: mdboom Date: 2008-12-26 16:28:04 +0000 (Fri, 26 Dec 2008) Log Message: ----------- Merge branch 'mathdefault' Modified Paths: -------------- 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/matplotlibrc.template Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2008-12-23 21:55:45 UTC (rev 6701) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2008-12-26 16:28:04 UTC (rev 6702) @@ -168,6 +168,7 @@ bf = T.Trait('serif:bold' , mplT.FontconfigPatternHandler()) sf = T.Trait('sans' , mplT.FontconfigPatternHandler()) fontset = T.Trait('cm', 'cm', 'stix', 'stixsans', 'custom') + default = T.Trait(*("rm cal it tt sf bf default bb frak circled scr regular".split())) fallback_to_cm = T.true class axes(TConfig): Modified: trunk/matplotlib/lib/matplotlib/config/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2008-12-23 21:55:45 UTC (rev 6701) +++ trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2008-12-26 16:28:04 UTC (rev 6702) @@ -209,6 +209,9 @@ validate_fontset = ValidateInStrings('fontset', ['cm', 'stix', 'stixsans', 'custom']) +validate_mathtext_default = ValidateInStrings( + 'default', "rm cal it tt sf bf default bb frak circled scr regular".split()) + validate_verbose = ValidateInStrings('verbose',[ 'silent', 'helpful', 'debug', 'debug-annoying', ]) @@ -371,6 +374,7 @@ 'mathtext.bf' : ['serif:bold', validate_font_properties], 'mathtext.sf' : ['sans\-serif', validate_font_properties], 'mathtext.fontset' : ['cm', validate_fontset], + 'mathtext.default' : ['it', validate_mathtext_default], 'mathtext.fallback_to_cm' : [True, validate_bool], 'image.aspect' : ['equal', validate_aspect], # equal, auto, a number Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2008-12-23 21:55:45 UTC (rev 6701) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008-12-26 16:28:04 UTC (rev 6702) @@ -403,7 +403,7 @@ *fontX*: one of the TeX font names:: - tt, it, rm, cal, sf, bf or default (non-math) + tt, it, rm, cal, sf, bf or default/regular (non-math) *fontclassX*: TODO @@ -419,7 +419,7 @@ """ *font*: one of the TeX font names:: - tt, it, rm, cal, sf, bf or default (non-math) + tt, it, rm, cal, sf, bf or default/regular (non-math) *font_class*: TODO @@ -543,6 +543,7 @@ filename = findfont(default_font_prop) default_font = self.CachedFont(FT2Font(str(filename))) self._fonts['default'] = default_font + self._fonts['regular'] = default_font def destroy(self): self.glyphd = None @@ -616,7 +617,7 @@ pclt = cached_font.font.get_sfnt_table('pclt') if pclt is None: # Some fonts don't store the xHeight, so we do a poor man's xHeight - metrics = self.get_metrics(font, 'it', 'x', fontsize, dpi) + metrics = self.get_metrics(font, rcParams['mathtext.default'], 'x', fontsize, dpi) return metrics.iceberg xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0) * (dpi / 100.0) return xHeight @@ -936,7 +937,7 @@ elif not doing_sans_conversion: # This will generate a dummy character uniindex = 0x1 - fontname = 'it' + fontname = rcParams['mathtext.default'] # Handle private use area glyphs if (fontname in ('it', 'rm', 'bf') and @@ -1007,6 +1008,7 @@ default_font.fname = filename self.fonts['default'] = default_font + self.fonts['regular'] = default_font self.pswriter = StringIO() def _get_font(self, font): @@ -2064,7 +2066,7 @@ _dropsub_symbols = set(r'''\int \oint'''.split()) - _fontnames = set("rm cal it tt sf bf default bb frak circled scr".split()) + _fontnames = set("rm cal it tt sf bf default bb frak circled scr regular".split()) _function_names = set(""" arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim @@ -2294,7 +2296,7 @@ def _get_font(self): return self._font def _set_font(self, name): - if name in ('it', 'rm', 'bf'): + if name in Parser._fontnames: self.font_class = name self._font = name font = property(_get_font, _set_font) @@ -2336,7 +2338,7 @@ hlist = Hlist(symbols) # We're going into math now, so set font to 'it' self.push_state() - self.get_state().font = 'it' + self.get_state().font = rcParams['mathtext.default'] return [hlist] def _make_space(self, percentage): @@ -2346,7 +2348,7 @@ width = self._em_width_cache.get(key) if width is None: metrics = state.font_output.get_metrics( - state.font, 'it', 'm', state.fontsize, state.dpi) + state.font, rcParams['mathtext.default'], 'm', state.fontsize, state.dpi) width = metrics.advance self._em_width_cache[key] = width return Kern(width * percentage) @@ -2665,7 +2667,7 @@ # Shift so the fraction line sits in the middle of the # equals sign metrics = state.font_output.get_metrics( - state.font, 'it', '=', state.fontsize, state.dpi) + state.font, rcParams['mathtext.default'], '=', state.fontsize, state.dpi) shift = (cden.height - ((metrics.ymax + metrics.ymin) / 2 - thickness * 3.0)) Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-12-23 21:55:45 UTC (rev 6701) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-12-26 16:28:04 UTC (rev 6702) @@ -233,6 +233,9 @@ validate_fontset = ValidateInStrings('fontset', ['cm', 'stix', 'stixsans', 'custom']) +validate_mathtext_default = ValidateInStrings( + 'default', "rm cal it tt sf bf default bb frak circled scr regular".split()) + validate_verbose = ValidateInStrings('verbose',[ 'silent', 'helpful', 'debug', 'debug-annoying', ]) @@ -397,6 +400,7 @@ 'mathtext.bf' : ['serif:bold', validate_font_properties], 'mathtext.sf' : ['sans\-serif', validate_font_properties], 'mathtext.fontset' : ['cm', validate_fontset], + 'mathtext.default' : ['it', validate_mathtext_default], 'mathtext.fallback_to_cm' : [True, validate_bool], 'image.aspect' : ['equal', validate_aspect], # equal, auto, a number Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2008-12-23 21:55:45 UTC (rev 6701) +++ trunk/matplotlib/matplotlibrc.template 2008-12-26 16:28:04 UTC (rev 6702) @@ -185,6 +185,11 @@ # fonts when a symbol can not be found in one of # the custom math fonts. +#mathtext.default : it # The default font to use for math. + # Can be any of the LaTeX font names, including + # the special name "regular" for the same font + # used in regular text. + ### AXES # default face and edge color, default tick sizes, # default fontsizes for ticklabels, and so on. See This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |