Revision: 4395
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4395&view=rev
Author: mdboom
Date: 2007-11-20 09:44:27 -0800 (Tue, 20 Nov 2007)
Log Message:
-----------
Merged revisions 4393-4394 via svnmerge from
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib
........
r4394 | mdboom | 2007-11-20 12:43:40 -0500 (Tue, 20 Nov 2007) | 3 lines
Minor refactorings, comments, and one bugfix (to do with the alignment
of wide accents with STIX fonts).
........
Modified Paths:
--------------
branches/transforms/lib/matplotlib/mathtext.py
Property Changed:
----------------
branches/transforms/
Property changes on: branches/transforms
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/matplotlib:1-4392
+ /trunk/matplotlib:1-4394
Modified: branches/transforms/lib/matplotlib/mathtext.py
===================================================================
--- branches/transforms/lib/matplotlib/mathtext.py 2007-11-20 17:43:40 UTC
(rev 4394)
+++ branches/transforms/lib/matplotlib/mathtext.py 2007-11-20 17:44:27 UTC
(rev 4395)
@@ -1707,6 +1707,7 @@
char = char_class(sym, state)
Hlist.__init__(self, [char])
+ self.width = char.width
class Ship(object):
"""Once the boxes have been set up, this sends them to output.
@@ -1742,11 +1743,14 @@
left_edge = self.cur_h
self.cur_s += 1
self.max_push = max(self.cur_s, self.max_push)
-
+ clamp = self.clamp
+
for p in box.children:
if isinstance(p, Char):
p.render(self.cur_h + self.off_h, self.cur_v + self.off_v)
self.cur_h += p.width
+ elif isinstance(p, Kern):
+ self.cur_h += p.width
elif isinstance(p, List):
# @623
if len(p.children) == 0:
@@ -1785,14 +1789,12 @@
if glue_sign == 1: # stretching
if glue_spec.stretch_order == glue_order:
cur_glue += glue_spec.stretch
- cur_g = round(self.clamp(float(box.glue_set) *
cur_glue))
+ cur_g = round(clamp(float(box.glue_set) *
cur_glue))
elif glue_spec.shrink_order == glue_order:
cur_glue += glue_spec.shrink
- cur_g = round(self.clamp(float(box.glue_set) *
cur_glue))
+ cur_g = round(clamp(float(box.glue_set) * cur_glue))
rule_width += cur_g
self.cur_h += rule_width
- elif isinstance(p, Kern):
- self.cur_h += p.width
self.cur_s -= 1
def vlist_out(self, box):
@@ -1805,9 +1807,12 @@
left_edge = self.cur_h
self.cur_v -= box.height
top_edge = self.cur_v
+ clamp = self.clamp
for p in box.children:
- if isinstance(p, List):
+ if isinstance(p, Kern):
+ self.cur_v += p.width
+ elif isinstance(p, List):
if len(p.children) == 0:
self.cur_v += p.height + p.depth
else:
@@ -1840,14 +1845,12 @@
if glue_sign == 1: # stretching
if glue_spec.stretch_order == glue_order:
cur_glue += glue_spec.stretch
- cur_g = round(self.clamp(float(box.glue_set) *
cur_glue))
+ cur_g = round(clamp(float(box.glue_set) *
cur_glue))
elif glue_spec.shrink_order == glue_order: # shrinking
cur_glue += glue_spec.shrink
- cur_g = round(self.clamp(float(box.glue_set) *
cur_glue))
+ cur_g = round(clamp(float(box.glue_set) * cur_glue))
rule_height += cur_g
self.cur_v += rule_height
- elif isinstance(p, Kern):
- self.cur_v += p.width
elif isinstance(p, Char):
raise RuntimeError("Internal mathtext error: Char node found
in vlist")
self.cur_s -= 1
@@ -1921,6 +1924,21 @@
_dropsub_symbols = Set(r'''\int \oint'''.split())
+ _fontnames = Set("rm cal it tt sf bf default bb frak circled scr".split())
+
+ _function_names = Set("""
+ arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim
+ liminf sin cos exp limsup sinh cosh gcd ln sup cot hom log tan
+ coth inf max tanh""".split())
+
+ _ambiDelim = Set(r"""
+ | \| / \backslash \uparrow \downarrow \updownarrow \Uparrow
+ \Downarrow \Updownarrow .""".split())
+
+ _leftDelim = Set(r"( [ { \lfloor \langle \lceil".split())
+
+ _rightDelim = Set(r") ] } \rfloor \rangle \rceil".split())
+
def __init__(self):
# All forward declarations are here
font = Forward().setParseAction(self.font).setName("font")
@@ -1944,15 +1962,10 @@
accent = oneOf(self._accent_map.keys() +
list(self._wide_accents))
- function = oneOf("arccos csc ker min arcsin deg lg Pr arctan det "
- "lim sec arg dim liminf sin cos exp limsup sinh "
- "cosh gcd ln sup cot hom log tan coth inf max "
- "tanh")
+ function = oneOf(list(self._function_names))
- fontname = oneOf("rm cal it tt sf bf")
- latex2efont = oneOf("mathrm mathcal mathit mathtt mathsf mathbf "
- "mathdefault mathbb mathfrak mathcircled "
- "mathscr")
+ fontname = oneOf(list(self._fontnames))
+ latex2efont = oneOf(['math' + x for x in self._fontnames])
space =(FollowedBy(bslash)
+ (Literal(r'\ ')
@@ -1991,7 +2004,8 @@
).setParseAction(self.accent).setName("accent")
function =(Suppress(bslash)
- +
function).setParseAction(self.function).setName("function")
+ + function
+ ).setParseAction(self.function).setName("function")
group = Group(
start_group
@@ -2063,11 +2077,9 @@
| placeable
)
- ambiDelim = oneOf(r"""| \| / \backslash \uparrow \downarrow
- \updownarrow \Uparrow \Downarrow
- \Updownarrow .""")
- leftDelim = oneOf(r"( [ { \lfloor \langle \lceil")
- rightDelim = oneOf(r") ] } \rfloor \rangle \rceil")
+ ambiDelim = oneOf(self._ambiDelim)
+ leftDelim = oneOf(self._leftDelim)
+ rightDelim = oneOf(self._rightDelim)
autoDelim <<(Suppress(Literal(r"\left"))
+ ((leftDelim | ambiDelim) | Error("Expected a
delimiter"))
+ Group(
@@ -2395,7 +2407,9 @@
super = next1
sub = next2
else:
- raise ParseFatalException("Subscript/superscript sequence is too
long. Use braces { } to remove ambiguity.")
+ raise ParseFatalException(
+ "Subscript/superscript sequence is too long. "
+ "Use braces { } to remove ambiguity.")
state = self.get_state()
rule_thickness = state.font_output.get_underline_thickness(
@@ -2403,6 +2417,7 @@
xHeight = state.font_output.get_xheight(
state.font, state.fontsize, state.dpi)
+ # Handle over/under symbols, such as sum or integral
if self.is_overunder(nucleus):
vlist = []
shift = 0.
@@ -2431,6 +2446,7 @@
result = Hlist([vlist])
return [result]
+ # Handle regular sub/superscripts
shift_up = nucleus.height - SUBDROP * xHeight
if self.is_dropsub(nucleus):
shift_down = nucleus.depth + SUBDROP * xHeight
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 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins