|
From: <md...@us...> - 2007-08-02 18:59:31
|
Revision: 3666
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3666&view=rev
Author: mdboom
Date: 2007-08-02 11:59:29 -0700 (Thu, 02 Aug 2007)
Log Message:
-----------
Add support for \widehat and \widetilde
Modified Paths:
--------------
trunk/matplotlib/examples/mathtext_examples.py
trunk/matplotlib/lib/matplotlib/_mathtext_data.py
trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/examples/mathtext_examples.py
===================================================================
--- trunk/matplotlib/examples/mathtext_examples.py 2007-08-02 18:49:17 UTC (rev 3665)
+++ trunk/matplotlib/examples/mathtext_examples.py 2007-08-02 18:59:29 UTC (rev 3666)
@@ -36,7 +36,8 @@
r'$\frac{x_2888}{y}$',
r"$\sqrt[3]{\frac{X_2}{Y}}=5$",
r"$\sqrt[3]{x}=5$",
- r'$\frac{X}{\frac{X}{Y}}$'
+ r'$\frac{X}{\frac{X}{Y}}$',
+ r'$\widehat{abc}\widetilde{def}$'
]
from pylab import *
Modified: trunk/matplotlib/lib/matplotlib/_mathtext_data.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/_mathtext_data.py 2007-08-02 18:49:17 UTC (rev 3665)
+++ trunk/matplotlib/lib/matplotlib/_mathtext_data.py 2007-08-02 18:59:29 UTC (rev 3666)
@@ -39,6 +39,8 @@
r'\}' : ('cmex10', 130),
r'\leftangle' : ('cmex10', 97),
r'\rightangle' : ('cmex10', 64),
+ r'\widehat' : ('cmex10', 15),
+ r'\widetilde' : ('cmex10', 52),
r'\omega' : ('cmmi10', 29),
r'\varepsilon' : ('cmmi10', 20),
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-02 18:49:17 UTC (rev 3665)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-02 18:59:29 UTC (rev 3666)
@@ -1437,7 +1437,7 @@
of some characters (such as the BaKoMa fonts), the correct glyph will
be selected, otherwise this will always just return a scaled version
of the glyph."""
- def __init__(self, c, width, state, always=False):
+ def __init__(self, c, width, state, always=False, char_class=Char):
alternatives = state.font_output.get_sized_alternatives_for_symbol(
state.font, c)
@@ -1445,7 +1445,7 @@
big_enough = False
for fontname, sym in alternatives:
state.font = fontname
- char = Char(sym, state)
+ char = char_class(sym, state)
if char.width > width:
big_enough = True
break
@@ -1455,7 +1455,7 @@
if not big_enough:
factor = width / char.width
state.fontsize *= factor
- char = Char(sym, state)
+ char = char_class(sym, state)
Hlist.__init__(self, [char])
@@ -1969,12 +1969,15 @@
raise ParseFatalException("Error parsing accent")
accent, sym = toks[0]
if accent in self._wide_accents:
- accent = AutoWidthChar(accent, sym.width, state)
+ accent = AutoWidthChar(
+ accent, sym.width, state, char_class=Accent)
+ shift_amount = 0.
else:
accent = Accent(self._accent_map[accent], state)
+ shift_amount = accent._metrics.xmin
centered = HCentered([accent])
centered.hpack(sym.width, 'exactly')
- centered.shift_amount = accent._metrics.xmin
+ centered.shift_amount = shift_amount
return Vlist([
centered,
Vbox(0., thickness * 2.0),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|