SourceForge logo
SourceForge logo
Menu

matplotlib-checkins

From: <md...@us...> - 2007年07月30日 18:57:15
Revision: 3635
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3635&view=rev
Author: mdboom
Date: 2007年07月30日 11:57:09 -0700 (2007年7月30日)
Log Message:
-----------
Improving spacing operators.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年07月30日 18:44:36 UTC (rev 3634)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年07月30日 18:57:09 UTC (rev 3635)
@@ -1698,13 +1698,17 @@
 space =(FollowedBy(bslash)
 + (Literal(r'\ ')
 | Literal(r'\/')
- | Group(Literal(r'\hspace{') + number + Literal('}'))
- )
+ | Literal(r',円')
+ | Literal(r'\;')
+ | Literal(r'\quad')
+ | Literal(r'\qquad')
+ | Literal(r'\!')
+ )
 ).setParseAction(self.space).setName('space')
 
 symbol = Regex("(" + ")|(".join(
 [
- r"\\(?!left[^a-z])(?!right[^a-z])[a-zA-Z0-9]+(?!{)",
+ r"\\(?!quad)(?!qquad)(?!left[^a-z])(?!right[^a-z])[a-zA-Z0-9]+(?!{)",
 r"[a-zA-Z0-9 ]",
 r"[+\-*/]",
 r"[<>=]",
@@ -1794,7 +1798,7 @@
 
 ambiDelim = oneOf(r"""| \| / \backslash \uparrow \downarrow
 \updownarrow \Uparrow \Downarrow
- \Updownarrow""")
+ \Updownarrow .""")
 leftDelim = oneOf(r"( [ { \lfloor \langle \lceil")
 rightDelim = oneOf(r") ] } \rfloor \rangle \rceil")
 autoDelim <<(Suppress(Literal(r"\left"))
@@ -1886,16 +1890,19 @@
 state = self.get_state()
 metrics = state.font_output.get_metrics(
 state.font, 'm', state.fontsize, state.dpi)
- em = metrics.width
- return Hbox(em * percentage)
- 
+ em = metrics.advance
+ return Kern(em * percentage)
+
+ _space_widths = { r'\ ' : 0.3,
+ r',円' : 0.4,
+ r'\;' : 0.8,
+ r'\quad' : 1.6,
+ r'\qquad' : 3.2,
+ r'\!' : -0.4,
+ r'\/' : 0.4 }
 def space(self, s, loc, toks):
 assert(len(toks)==1)
- if toks[0]==r'\ ': num = 0.30 # 30% of fontsize
- elif toks[0]==r'\/': num = 0.1 # 10% of fontsize
- else: # hspace
- num = float(toks[0][1]) # get the num out of \hspace{num}
-
+ num = self._space_widths[toks[0]]
 box = self._make_space(num)
 return [box]
 
@@ -2179,10 +2186,13 @@
 state = self.get_state()
 height = max([x.height for x in middle])
 depth = max([x.depth for x in middle])
- hlist = Hlist(
- [AutoSizedDelim(front, height, depth, state)] +
- middle.asList() +
- [AutoSizedDelim(back, height, depth, state)])
+ parts = []
+ if front != '.':
+ parts.append(AutoSizedDelim(front, height, depth, state))
+ parts.extend(middle.asList())
+ if back != '.':
+ parts.append(AutoSizedDelim(back, height, depth, state))
+ hlist = Hlist(parts)
 return hlist
 
 ####
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月01日 13:51:49
Revision: 3654
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3654&view=rev
Author: mdboom
Date: 2007年08月01日 06:51:48 -0700 (2007年8月01日)
Log Message:
-----------
Use Python lists rather than linked lists to improve speed
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月01日 13:06:07 UTC (rev 3653)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月01日 13:51:48 UTC (rev 3654)
@@ -850,30 +850,26 @@
 # Percentage of x-height of additional horiz. space after sub/superscripts
 SCRIPT_SPACE = 0.3
 # Percentage of x-height that sub/superscripts drop below the baseline
-SUBDROP = 0.4
+SUBDROP = 0.3
 # Percentage of x-height that superscripts drop below the baseline
 SUP1 = 0.7
 # Percentage of x-height that subscripts drop below the baseline
 SUB1 = 0.0
 # Percentage of x-height that superscripts are offset relative to the subscript
-DELTA = 0.1
+DELTA = 0.25
 
 class MathTextWarning(Warning):
 pass
 
 class Node(object):
- """A node in a linked list.
+ """A node in the TeX box model
 @133
 """
 def __init__(self):
- self.link = None
 self.size = 0
 
 def __repr__(self):
- s = self.__internal_repr__()
- if self.link:
- s += ' ' + self.link.__repr__()
- return s
+ return self.__internal_repr__()
 
 def __internal_repr__(self):
 return self.__class__.__name__
@@ -881,21 +877,14 @@
 def get_kerning(self, next):
 return 0.0
 
- def set_link(self, other):
- self.link = other
-
 def shrink(self):
 """Shrinks one level smaller. There are only three levels of sizes,
 after which things will no longer get smaller."""
- if self.link:
- self.link.shrink()
 self.size += 1
 
 def grow(self):
 """Grows one level larger. There is no limit to how big something
 can get."""
- if self.link:
- self.link.grow()
 self.size -= 1
 
 def render(self, x, y):
@@ -1027,29 +1016,17 @@
 def __init__(self, elements):
 Box.__init__(self, 0., 0., 0.)
 self.shift_amount = 0. # An arbitrary offset
- self.list_head = None # The head of a linked list of Nodes in this box
+ self.children = elements # The child nodes of this list
 # The following parameters are set in the vpack and hpack functions
 self.glue_set = 0. # The glue setting of this list
 self.glue_sign = 0 # 0: normal, -1: shrinking, 1: stretching
 self.glue_order = 0 # The order of infinity (0 - 3) for the glue
- 
- # Convert the Python list to a linked list
- if len(elements):
- elem = self.list_head = elements[0]
- for next in elements[1:]:
- elem.set_link(next)
- elem = next
 
 def __repr__(self):
- s = '[%s <%d %d %d %d> ' % (self.__internal_repr__(),
- self.width, self.height,
- self.depth, self.shift_amount)
- if self.list_head:
- s += ' ' + self.list_head.__repr__()
- s += ']'
- if self.link:
- s += ' ' + self.link.__repr__()
- return s
+ return '[%s <%d %d %d %d> %s]' % (self.__internal_repr__(),
+ self.width, self.height,
+ self.depth, self.shift_amount,
+ ' '.join(self.children))
 
 def _determine_order(self, totals):
 """A helper function to determine the highest order of glue
@@ -1071,21 +1048,21 @@
 self.glue_sign = 0
 self.glue_ratio = 0.
 if o == 0:
- if self.list_head is not None:
+ if len(self.children):
 warn("%s %s: %r" % (error_type, self.__class__.__name__, self),
 MathTextWarning)
 
 def shrink(self):
- if self.list_head:
- self.list_head.shrink()
+ for child in self.children:
+ child.shrink()
 Box.shrink(self)
 if self.size < NUM_SIZE_LEVELS:
 self.shift_amount *= SHRINK_FACTOR
 self.glue_set *= SHRINK_FACTOR
 
 def grow(self):
- if self.list_head:
- self.list_head.grow()
+ for child in self.children:
+ child.grow()
 Box.grow(self)
 self.shift_amount *= INV_SHRINK_FACTOR
 self.glue_set *= INV_SHRINK_FACTOR
@@ -1103,15 +1080,21 @@
 Chars themselves determine the amount of kerning they need
 (in get_kerning), and this function just creates the linked
 list in the correct way."""
- elem = self.list_head
- while elem is not None:
- next = elem.link
+ new_children = []
+ num_children = len(self.children)
+ for i in range(num_children):
+ elem = self.children[i]
+ if i < num_children - 1:
+ next = self.children[i + 1]
+ else:
+ next = None
+
+ new_children.append(elem)
 kerning_distance = elem.get_kerning(next)
 if kerning_distance != 0.:
 kern = Kern(kerning_distance)
- elem.link = kern
- kern.link = next
- elem = next
+ new_children.append(kern)
+ self.children = new_children
 
 def hpack(self, w=0., m='additional'):
 """The main duty of hpack is to compute the dimensions of the
@@ -1136,18 +1119,12 @@
 x = 0.
 total_stretch = [0.] * 4
 total_shrink = [0.] * 4
- p = self.list_head
- while p is not None:
- # Layout characters in a tight inner loop (common case)
- while isinstance(p, Char):
+ for p in self.children:
+ if isinstance(p, Char):
 x += p.width
 h = max(h, p.height)
 d = max(d, p.depth)
- p = p.link # Go to next node in list
- if p is None:
- break
- 
- if isinstance(p, Box):
+ elif isinstance(p, Box):
 x += p.width
 if p.height is not None and p.depth is not None:
 s = getattr(p, 'shift_amount', 0.)
@@ -1160,7 +1137,6 @@
 total_shrink[glue_spec.shrink_order] += glue_spec.shrink
 elif isinstance(p, Kern):
 x += p.width
- p = p.link # Go to next node in list
 self.height = h
 self.depth = d
 
@@ -1207,11 +1183,8 @@
 x = 0.
 total_stretch = [0.] * 4
 total_shrink = [0.] * 4
- p = self.list_head
- while p is not None:
- if isinstance(p, Char):
- raise RuntimeError("Internal mathtext error: Char node found in Vlist.")
- elif isinstance(p, Box):
+ for p in self.children:
+ if isinstance(p, Box):
 x += d + p.height
 d = p.depth
 if p.width is not None:
@@ -1227,8 +1200,9 @@
 elif isinstance(p, Kern):
 x += d + p.width
 d = 0.
- p = p.link
-
+ elif isinstance(p, Char):
+ raise RuntimeError("Internal mathtext error: Char node found in Vlist.")
+ 
 self.width = w
 if d > l:
 x += d - l
@@ -1482,23 +1456,18 @@
 cur_glue = 0.
 glue_order = box.glue_order
 glue_sign = box.glue_sign
- p = box.list_head
 base_line = self.cur_v
 left_edge = self.cur_h
 self.cur_s += 1
 self.max_push = max(self.cur_s, self.max_push)
 
- while p:
- while isinstance(p, Char):
+ 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
- p = p.link
- if p is None:
- break
- 
- if isinstance(p, List):
+ elif isinstance(p, List):
 # @623
- if p.list_head is None:
+ if len(p.children) == 0:
 self.cur_h += p.width
 else:
 edge = self.cur_h
@@ -1542,7 +1511,6 @@
 self.cur_h += rule_width
 elif isinstance(p, Kern):
 self.cur_h += p.width
- p = p.link
 self.cur_s -= 1
 
 def vlist_out(self, box):
@@ -1550,18 +1518,15 @@
 cur_glue = 0.
 glue_order = box.glue_order
 glue_sign = box.glue_sign
- p = box.list_head
 self.cur_s += 1
 self.max_push = max(self.max_push, self.cur_s)
 left_edge = self.cur_h
 self.cur_v -= box.height
 top_edge = self.cur_v
 
- while p:
- if isinstance(p, Char):
- raise RuntimeError("Internal mathtext error: Char node found in vlist")
- elif isinstance(p, List):
- if p.list_head is None:
+ for p in box.children:
+ if isinstance(p, List):
+ if len(p.children) == 0:
 self.cur_v += p.height + p.depth
 else:
 self.cur_v += p.height
@@ -1601,8 +1566,8 @@
 self.cur_v += rule_height
 elif isinstance(p, Kern):
 self.cur_v += p.width
- 
- p = p.link
+ elif isinstance(p, Char):
+ raise RuntimeError("Internal mathtext error: Char node found in vlist")
 self.cur_s -= 1
 
 ship = Ship()
@@ -1657,7 +1622,7 @@
 _punctuation_symbols = Set(r', ; . ! \ldotp \cdotp'.split())
 
 _overunder_symbols = Set(r'''
- \sum \prod \int \coprod \oint \bigcap \bigcup \bigsqcup \bigvee
+ \sum \prod \coprod \bigcap \bigcup \bigsqcup \bigvee
 \bigwedge \bigodot \bigotimes \bigoplus \biguplus
 '''.split()
 )
@@ -1665,6 +1630,8 @@
 _overunder_functions = Set(
 r"lim liminf limsup sup max min".split()
 )
+
+ _dropsub_symbols = Set(r'''\int \oint'''.split())
 
 def __init__(self):
 # All forward declarations are here
@@ -1843,6 +1810,7 @@
 def clear(self):
 self._expr = None
 self._state_stack = None
+ self._em_width_cache = {}
 
 def parse(self, s, fonts_object, fontsize, dpi):
 self._state_stack = [self.State(fonts_object, 'default', fontsize, dpi)]
@@ -1898,10 +1866,14 @@
 def _make_space(self, percentage):
 # All spaces are relative to em width
 state = self.get_state()
- metrics = state.font_output.get_metrics(
- state.font, 'm', state.fontsize, state.dpi)
- em = metrics.advance
- return Kern(em * percentage)
+ key = (state.font, state.fontsize, state.dpi)
+ width = self._em_width_cache.get(key)
+ if width is None:
+ metrics = state.font_output.get_metrics(
+ state.font, 'm', state.fontsize, state.dpi)
+ width = metrics.advance
+ self._em_width_cache[key] = width
+ return Kern(width * percentage)
 
 _space_widths = { r'\ ' : 0.3,
 r',円' : 0.4,
@@ -1919,17 +1891,19 @@
 def symbol(self, s, loc, toks):
 # print "symbol", toks
 c = toks[0]
+ try:
+ char = Char(c, self.get_state())
+ except ValueError:
+ raise ParseFatalException("Unknown symbol: %s" % c)
+
 if c in self._spaced_symbols:
 return [Hlist( [self._make_space(0.2),
- Char(c, self.get_state()),
+ char,
 self._make_space(0.2)] )]
 elif c in self._punctuation_symbols:
- return [Hlist( [Char(c, self.get_state()),
+ return [Hlist( [char,
 self._make_space(0.2)] )]
- try:
- return [Char(toks[0], self.get_state())]
- except ValueError:
- raise ParseFatalException("Unknown symbol: %s" % c)
+ return [char]
 
 _accent_map = {
 r'\hat' : r'\circumflexaccent',
@@ -2004,6 +1978,11 @@
 elif isinstance(nucleus, Hlist) and hasattr(nucleus, 'function_name'):
 return nucleus.function_name in self._overunder_functions
 return False
+
+ def is_dropsub(self, nucleus):
+ if isinstance(nucleus, Char):
+ return nucleus.c in self._dropsub_symbols
+ return False
 
 def subsuperscript(self, s, loc, toks):
 assert(len(toks)==1)
@@ -2079,7 +2058,10 @@
 return [result]
 
 shift_up = nucleus.height - SUBDROP * xHeight
- shift_down = SUBDROP * xHeight
+ if self.is_dropsub(nucleus):
+ shift_down = nucleus.depth + SUBDROP * xHeight
+ else:
+ shift_down = SUBDROP * xHeight
 if super is None:
 # @757
 sub.shrink()
@@ -2091,8 +2073,8 @@
 x.shift_amount = shift_down
 else:
 super.shrink()
- x = Hlist([super])
- x.width += SCRIPT_SPACE * xHeight
+ x = Hlist([super, Kern(SCRIPT_SPACE * xHeight)])
+ # x.width += SCRIPT_SPACE * xHeight
 clr = SUP1 * xHeight
 shift_up = max(shift_up, clr)
 clr = x.depth + (abs(xHeight) / 4.0)
@@ -2104,11 +2086,11 @@
 y = Hlist([sub])
 y.width += SCRIPT_SPACE * xHeight
 shift_down = max(shift_down, SUB1 * xHeight)
- clr = 4.0 * rule_thickness - ((shift_up - x.depth) - (y.height - shift_down))
+ clr = 2.0 * rule_thickness - ((shift_up - x.depth) - (y.height - shift_down))
 if clr > 0.:
 shift_up += clr
 shift_down += clr
- x.shift_amount = DELTA * xHeight
+ x.shift_amount = DELTA * (shift_up + shift_down)
 x = Vlist([x,
 Kern((shift_up - x.depth) - (y.height - shift_down)),
 y])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月01日 15:35:58
Revision: 3659
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3659&view=rev
Author: mdboom
Date: 2007年08月01日 08:35:54 -0700 (2007年8月01日)
Log Message:
-----------
Use numpy.inf
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月01日 15:07:29 UTC (rev 3658)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月01日 15:35:54 UTC (rev 3659)
@@ -135,6 +135,7 @@
 from sets import Set
 from unicodedata import category
 from warnings import warn
+import numpy
 
 from matplotlib import verbose
 from matplotlib.pyparsing import Literal, Word, OneOrMore, ZeroOrMore, \
@@ -607,7 +608,11 @@
 r'\backslash': [('cal', '\x6e'), ('ex', '\xb2'), ('ex', '\x2f'),
 ('ex', '\xc2'), ('ex', '\x2d')],
 r'/' : [('rm', '/'), ('ex', '\xb1'), ('ex', '\x2e'),
- ('ex', '\xcb'), ('ex', '\x2c')]
+ ('ex', '\xcb'), ('ex', '\x2c')],
+ r'\widehat' : [('rm', '\x5e'), ('ex', '\x62'), ('ex', '\x63'),
+ ('ex', '\x64')],
+ r'\widetilde': [('rm', '\x7e'), ('ex', '\x65'), ('ex', '\x66'),
+ ('ex', '\x67')]
 }
 
 for alias, target in [('\leftparen', '('),
@@ -1162,7 +1167,7 @@
 List.__init__(self, elements)
 self.vpack()
 
- def vpack(self, h=0., m='additional', l=float('inf')):
+ def vpack(self, h=0., m='additional', l=float(numpy.inf)):
 """The main duty of vpack is to compute the dimensions of the
 resulting boxes, and to adjust the glue if one of those dimensions is
 pre-specified.
@@ -1395,7 +1400,7 @@
 self.super = None
 Hlist.__init__(self, [])
 
-class AutoSizedDelim(Hlist):
+class AutoHeightChar(Hlist):
 """A class that will create a character as close to the given height
 and depth as possible. When using a font with multiple height versions
 of some characters (such as the BaKoMa fonts), the correct glyph will
@@ -1425,6 +1430,34 @@
 shift = (depth - char.depth)
 Hlist.__init__(self, [char])
 self.shift_amount = shift
+
+class AutoWidthChar(Hlist):
+ """A class that will create a character as close to the given width
+ as possible. When using a font with multiple width versions
+ 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):
+ alternatives = state.font_output.get_sized_alternatives_for_symbol(
+ state.font, c)
+
+ state = state.copy()
+ big_enough = False
+ for fontname, sym in alternatives:
+ state.font = fontname
+ char = Char(sym, state)
+ if char.width > width:
+ big_enough = True
+ break
+
+ # If the largest option is still not big enough, just do
+ # simple scale on it.
+ if not big_enough:
+ factor = width / char.width
+ state.fontsize *= factor
+ char = Char(sym, state)
+ 
+ Hlist.__init__(self, [char])
 
 class Ship(object):
 """Once the boxes have been set up, this sends them to output.
@@ -1653,7 +1686,7 @@
 bslash = Literal('\\')
 
 accent = oneOf("hat check dot breve acute ddot grave tilde bar "
- "vec \" ` ' ~ . ^")
+ "vec \" ` ' ~ . ^ widehat widetilde")
 
 function = oneOf("arccos csc ker min arcsin deg lg Pr arctan det "
 "lim sec arg dim liminf sin cos exp limsup sinh "
@@ -1920,8 +1953,10 @@
 r"\'" : r'\combiningacuteaccent',
 r'\~' : r'\combiningtilde',
 r'\.' : r'\combiningdotabove',
- r'\^' : r'\circumflexaccent',
+ r'\^' : r'\circumflexaccent'
 }
+
+ _wide_accents = Set(r"\widehat \widetilde".split())
 
 def accent(self, s, loc, toks):
 assert(len(toks)==1)
@@ -1931,7 +1966,10 @@
 if len(toks[0]) != 2:
 raise ParseFatalException("Error parsing accent")
 accent, sym = toks[0]
- accent = Accent(self._accent_map[accent], self.get_state())
+ if accent in self._wide_accents:
+ accent = AutoWidthChar(accent, sym.width, state)
+ else:
+ accent = Accent(self._accent_map[accent], state)
 centered = HCentered([accent])
 centered.hpack(sym.width, 'exactly')
 centered.shift_amount = accent._metrics.xmin
@@ -2154,7 +2192,7 @@
 # the height so it doesn't seem cramped
 height = body.height - body.shift_amount + thickness * 5.0
 depth = body.depth + body.shift_amount
- check = AutoSizedDelim(r'\sqrt', height, depth, state, always=True)
+ check = AutoHeightChar(r'\sqrt', height, depth, state, always=True)
 height = check.height - check.shift_amount
 depth = check.depth + check.shift_amount
 
@@ -2190,10 +2228,10 @@
 parts = []
 # \left. and \right. aren't supposed to produce any symbols
 if front != '.':
- parts.append(AutoSizedDelim(front, height, depth, state))
+ parts.append(AutoHeightChar(front, height, depth, state))
 parts.extend(middle.asList())
 if back != '.':
- parts.append(AutoSizedDelim(back, height, depth, state))
+ parts.append(AutoHeightChar(back, height, depth, state))
 hlist = Hlist(parts)
 return hlist
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月02日 15:15:37
Revision: 3663
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3663&view=rev
Author: mdboom
Date: 2007年08月02日 08:15:29 -0700 (2007年8月02日)
Log Message:
-----------
Minor mathtext bugfixes
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月01日 17:28:58 UTC (rev 3662)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月02日 15:15:29 UTC (rev 3663)
@@ -1031,7 +1031,7 @@
 return '[%s <%d %d %d %d> %s]' % (self.__internal_repr__(),
 self.width, self.height,
 self.depth, self.shift_amount,
- ' '.join(self.children))
+ ' '.join([repr(x) for x in self.children]))
 
 def _determine_order(self, totals):
 """A helper function to determine the highest order of glue
@@ -2104,7 +2104,7 @@
 # @757
 sub.shrink()
 x = Hlist([sub])
- x.width += SCRIPT_SPACE * xHeight
+ # x.width += SCRIPT_SPACE * xHeight
 shift_down = max(shift_down, SUB1)
 clr = x.height - (abs(xHeight * 4.0) / 5.0)
 shift_down = max(shift_down, clr)
@@ -2122,7 +2122,7 @@
 else: # Both sub and superscript
 sub.shrink()
 y = Hlist([sub])
- y.width += SCRIPT_SPACE * xHeight
+ # y.width += SCRIPT_SPACE * xHeight
 shift_down = max(shift_down, SUB1 * xHeight)
 clr = 2.0 * rule_thickness - ((shift_up - x.depth) - (y.height - shift_down))
 if clr > 0.:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月02日 19:07:35
Revision: 3667
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3667&view=rev
Author: mdboom
Date: 2007年08月02日 12:07:02 -0700 (2007年8月02日)
Log Message:
-----------
Small bugfix with auto-sized delimiters
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月02日 18:59:29 UTC (rev 3666)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月02日 19:07:02 UTC (rev 3667)
@@ -1412,20 +1412,15 @@
 
 state = state.copy()
 target_total = height + depth
- big_enough = False
 for fontname, sym in alternatives:
 state.font = fontname
 char = Char(sym, state)
- if char.height + char.depth > target_total:
- big_enough = True
+ if char.height + char.depth >= target_total:
 break
 
- # If the largest option is still not big enough, just do
- # simple scale on it.
- if not big_enough:
- factor = target_total / (char.height + char.depth)
- state.fontsize *= factor
- char = Char(sym, state)
+ factor = target_total / (char.height + char.depth)
+ state.fontsize *= factor
+ char = Char(sym, state)
 
 shift = (depth - char.depth)
 Hlist.__init__(self, [char])
@@ -1442,20 +1437,15 @@
 state.font, c)
 
 state = state.copy()
- big_enough = False
 for fontname, sym in alternatives:
 state.font = fontname
 char = char_class(sym, state)
- if char.width > width:
- big_enough = True
+ if char.width >= width:
 break
 
- # If the largest option is still not big enough, just do
- # simple scale on it.
- if not big_enough:
- factor = width / char.width
- state.fontsize *= factor
- char = char_class(sym, state)
+ factor = width / char.width
+ state.fontsize *= factor
+ char = char_class(sym, state)
 
 Hlist.__init__(self, [char])
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月13日 14:29:52
Revision: 3704
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3704&view=rev
Author: mdboom
Date: 2007年08月13日 07:29:49 -0700 (2007年8月13日)
Log Message:
-----------
Fix spacing of operators (particularly with custom fonts).
Fix positioning of accents.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月13日 12:55:27 UTC (rev 3703)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月13日 14:29:49 UTC (rev 3704)
@@ -1098,7 +1098,7 @@
 def _update_metrics(self):
 metrics = self._metrics = self.font_output.get_metrics(
 self.font, self.c, self.fontsize, self.dpi)
- self.width = metrics.width
+ self.width = metrics.xmax - metrics.xmin
 self.height = metrics.ymax - metrics.ymin
 self.depth = 0
 
@@ -1169,9 +1169,10 @@
 class Hlist(List):
 """A horizontal list of boxes.
 @135"""
- def __init__(self, elements, w=0., m='additional'):
+ def __init__(self, elements, w=0., m='additional', do_kern=True):
 List.__init__(self, elements)
- self.kern()
+ if do_kern:
+ self.kern()
 self.hpack()
 
 def kern(self):
@@ -1453,14 +1454,10 @@
 class HCentered(Hlist):
 """A convenience class to create an Hlist whose contents are centered
 within its enclosing box."""
- def __init__(self, elements, is_accent = False):
+ def __init__(self, elements):
 self.is_accent = is_accent
- Hlist.__init__(self, [SsGlue()] + elements + [SsGlue()])
-
- def kern(self):
- Hlist.kern(self)
- if not self.is_accent and isinstance(self.children[-2], Kern):
- self.children = self.children[:-2] + [SsGlue()]
+ Hlist.__init__(self, [SsGlue()] + elements + [SsGlue()],
+ do_kern=False)
 
 class VCentered(Hlist):
 """A convenience class to create an Vlist whose contents are centered
@@ -2028,10 +2025,12 @@
 if c in self._spaced_symbols:
 return [Hlist( [self._make_space(0.2),
 char,
- self._make_space(0.2)] )]
+ self._make_space(0.2)] ,
+ do_kern = False)]
 elif c in self._punctuation_symbols:
 return [Hlist( [char,
- self._make_space(0.2)] )]
+ self._make_space(0.2)] ,
+ do_kern = False)]
 return [char]
 
 _accent_map = {
@@ -2065,13 +2064,10 @@
 if accent in self._wide_accents:
 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], is_accent=True)
+ centered = HCentered([accent])
 centered.hpack(sym.width, 'exactly')
- 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.
From: <md...@us...> - 2007年08月13日 14:32:20
Revision: 3705
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3705&view=rev
Author: mdboom
Date: 2007年08月13日 07:32:15 -0700 (2007年8月13日)
Log Message:
-----------
Fix typo.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月13日 14:29:49 UTC (rev 3704)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月13日 14:32:15 UTC (rev 3705)
@@ -1455,7 +1455,6 @@
 """A convenience class to create an Hlist whose contents are centered
 within its enclosing box."""
 def __init__(self, elements):
- self.is_accent = is_accent
 Hlist.__init__(self, [SsGlue()] + elements + [SsGlue()],
 do_kern=False)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月20日 12:47:10
Revision: 3716
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3716&view=rev
Author: mdboom
Date: 2007年08月20日 05:46:53 -0700 (2007年8月20日)
Log Message:
-----------
Remove a Unicode character
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月17日 22:36:01 UTC (rev 3715)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月20日 12:46:53 UTC (rev 3716)
@@ -176,9 +176,9 @@
 or a Type1 symbol name (i.e. 'phi').
 
 """
- # From UTF #25: U+2212 − minus sign is the preferred
+ # From UTF #25: U+2212 minus sign is the preferred
 # representation of the unary and binary minus sign rather than
- # the ASCII-derived U+002D - hyphen-minus, because minus sign is
+ # the ASCII-derived U+002D hyphen-minus, because minus sign is
 # unambiguous and because it is rendered with a more desirable
 # length, usually longer than a hyphen.
 if symbol == '-':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月27日 18:51:29
Revision: 3739
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3739&view=rev
Author: mdboom
Date: 2007年08月27日 11:51:22 -0700 (2007年8月27日)
Log Message:
-----------
Cleaned up some comments.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月27日 15:42:44 UTC (rev 3738)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月27日 18:51:22 UTC (rev 3739)
@@ -116,11 +116,6 @@
 
 - Certainly there are some...
 
-STATUS:
- The *Unicode* classes were incomplete when I found them, and have
- not been refactored to support intermingling of regular text and
- math text yet. They are most likely broken. -- Michael Droettboom, July 2007
-
 Author : John Hunter <jdh...@ac...>
 Michael Droettboom <md...@st...>
 (rewrite based on TeX box layout algorithms)
@@ -2400,9 +2395,3 @@
 font_output.mathtext_backend.fonts_object = None
 
 return result
-
-# math_parse_s_ft2font = math_parse_s_ft2font_common('Agg')
-# math_parse_s_ft2font_svg = math_parse_s_ft2font_common('SVG')
-# math_parse_s_ps = math_parse_s_ft2font_common('PS')
-# math_parse_s_pdf = math_parse_s_ft2font_common('PDF')
-# math_parse_s_cairo = math_parse_s_ft2font_common('Cairo')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月27日 19:32:41
Revision: 3740
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3740&view=rev
Author: mdboom
Date: 2007年08月27日 12:32:38 -0700 (2007年8月27日)
Log Message:
-----------
Better mathtext error messages. Fix bug when using \sqrt without
explicit root.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月27日 18:51:22 UTC (rev 3739)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月27日 19:32:38 UTC (rev 3740)
@@ -1932,7 +1932,14 @@
 
 def parse(self, s, fonts_object, fontsize, dpi):
 self._state_stack = [self.State(fonts_object, 'default', fontsize, dpi)]
- self._expression.parseString(s)
+ try:
+ self._expression.parseString(s)
+ except ParseException, err:
+ raise ValueError("\n".join([
+ "",
+ err.line,
+ " " * (err.column - 1) + "^",
+ str(err)]))
 return self._expr
 
 # The state of the parser is maintained in a stack. Upon
@@ -2155,7 +2162,7 @@
 super = next1
 sub = next2
 else:
- raise ParseFatalException("Subscript/superscript sequence is too long.")
+ 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(
@@ -2277,7 +2284,7 @@
 state.font, state.fontsize, state.dpi)
 
 if root is None:
- root = Box()
+ root = Box(0., 0., 0.)
 else:
 if not isinstance(root, ParseResults):
 raise ParseFatalException(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月30日 13:41:54
Revision: 3755
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3755&view=rev
Author: mdboom
Date: 2007年08月30日 06:41:52 -0700 (2007年8月30日)
Log Message:
-----------
Fixes bounding box bug with Agg backend.
Fixes spacing bug when using standard Ps fonts.
Reduces memory usage by not caching mathtext expressions for too long.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月30日 13:38:22 UTC (rev 3754)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月30日 13:41:52 UTC (rev 3755)
@@ -253,9 +253,9 @@
 
 def render_glyph(self, ox, oy, info):
 self._update_bbox(ox + info.metrics.xmin,
- oy + info.metrics.ymin,
+ oy - info.metrics.ymax,
 ox + info.metrics.xmax,
- oy + info.metrics.ymax)
+ oy - info.metrics.ymin)
 
 def render_rect_filled(self, x1, y1, x2, y2):
 self._update_bbox(x1, y1, x2, y2)
@@ -265,7 +265,8 @@
 bbox = self.bbox
 bbox = [bbox[0] - 2, bbox[1] - 2, bbox[2] + 2, bbox[3] + 2]
 self._switch_to_real_backend()
- self.fonts_object.set_canvas_size(bbox[2] - bbox[0], bbox[3] - bbox[1])
+ self.fonts_object.set_canvas_size(
+ bbox[2] - bbox[0], bbox[3] - bbox[1])
 ship(-bbox[0], -bbox[1], box)
 return self.fonts_object.get_results(box)
 
@@ -321,6 +322,8 @@
 fontsize = info.fontsize
 symbol_name = info.symbol_name
 
+ # TODO: Optimize out the font changes
+ 
 ps = """/%(postscript_name)s findfont
 %(fontsize)s scalefont
 setfont
@@ -928,7 +931,7 @@
 xmin, ymin, xmax, ymax = [val * scale
 for val in font.get_bbox_char(glyph)]
 metrics = Bunch(
- advance = (xmax-xmin),
+ advance = font.get_width_char(glyph) * scale,
 width = font.get_width_char(glyph) * scale,
 height = font.get_height_char(glyph) * scale,
 xmin = xmin,
@@ -2439,6 +2442,7 @@
 cacheKey = (s, dpi, hash(prop))
 result = self._cache.get(cacheKey)
 if result is not None:
+ del self._cache[cacheKey]
 return result
 
 if self._output == 'PS' and rcParams['ps.useafm']:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月30日 13:51:12
Revision: 3756
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3756&view=rev
Author: mdboom
Date: 2007年08月30日 06:51:10 -0700 (2007年8月30日)
Log Message:
-----------
Reduce Ps files sizes when using mathtext
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月30日 13:41:52 UTC (rev 3755)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年08月30日 13:51:10 UTC (rev 3756)
@@ -315,6 +315,7 @@
 class MathtextBackendPs(MathtextBackend):
 def __init__(self):
 self.pswriter = StringIO()
+ self.lastfont = None
 
 def render_glyph(self, ox, oy, info):
 oy = self.height - oy + info.offset
@@ -322,12 +323,15 @@
 fontsize = info.fontsize
 symbol_name = info.symbol_name
 
- # TODO: Optimize out the font changes
- 
- ps = """/%(postscript_name)s findfont
+ if (postscript_name, fontsize) != self.lastfont:
+ ps = """/%(postscript_name)s findfont
 %(fontsize)s scalefont
 setfont
-%(ox)f %(oy)f moveto
+""" % locals()
+ self.lastfont = postscript_name, fontsize
+ self.pswriter.write(ps)
+ 
+ ps = """%(ox)f %(oy)f moveto
 /%(symbol_name)s glyphshow\n
 """ % locals()
 self.pswriter.write(ps)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年09月04日 19:29:47
Revision: 3777
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3777&view=rev
Author: mdboom
Date: 2007年09月04日 12:29:45 -0700 (2007年9月04日)
Log Message:
-----------
Better error messages.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年09月04日 19:00:18 UTC (rev 3776)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年09月04日 19:29:45 UTC (rev 3777)
@@ -138,7 +138,7 @@
 Combine, Group, Optional, Forward, NotAny, alphas, nums, alphanums, \
 StringStart, StringEnd, ParseFatalException, FollowedBy, Regex, \
 operatorPrecedence, opAssoc, ParseResults, Or, Suppress, oneOf, \
- ParseException, MatchFirst, NoMatch
+ ParseException, MatchFirst, NoMatch, Empty
 
 from matplotlib.afm import AFM
 from matplotlib.cbook import enumerate, iterable, Bunch, get_realpath_and_stat, \
@@ -1787,6 +1787,14 @@
 ##############################################################################
 # PARSER
 
+def Error(msg):
+ def raise_error(s, loc, toks):
+ raise ParseFatalException(msg)
+
+ empty = Empty()
+ empty.setParseAction(raise_error)
+ return empty
+ 
 class Parser(object):
 _binary_operators = Set(r'''
 + *
@@ -1887,9 +1895,10 @@
 ).setParseAction(self.space).setName('space')
 
 customspace =(Literal(r'\hspace')
- + lbrace
- + float
- + rbrace
+ + (( lbrace
+ + float
+ + rbrace
+ ) | Error(r"Expected \hspace{n}"))
 ).setParseAction(self.customspace).setName('customspace')
 
 symbol =(Regex(r"([a-zA-Z0-9 +\-*/<>=:,.;!'@()])|(\\[%${}\[\]])")
@@ -1926,8 +1935,8 @@
 bslash
 + Literal("frac")
 )
- + group
- + group
+ + ((group + group)
+ | Error(r"Expected \frac{num}{den}"))
 ).setParseAction(self.frac).setName("frac")
 
 sqrt = Group(
@@ -1946,7 +1955,7 @@
 + Suppress(Literal("]")),
 default = None
 )
- + group
+ + (group | Error("Expected \sqrt{value}"))
 ).setParseAction(self.sqrt).setName("sqrt")
 
 placeable <<(accent
@@ -1955,7 +1964,7 @@
 ^ group
 ^ frac
 ^ sqrt
- )
+ ) | Error("Expected symbol or group")
 
 simple <<(space
 | customspace 
@@ -1983,12 +1992,12 @@
 leftDelim = oneOf(r"( [ { \lfloor \langle \lceil")
 rightDelim = oneOf(r") ] } \rfloor \rangle \rceil")
 autoDelim <<(Suppress(Literal(r"\left"))
- + (leftDelim | ambiDelim)
+ + ((leftDelim | ambiDelim) | Error("Expected a delimiter"))
 + Group(
 autoDelim
 ^ OneOrMore(simple))
 + Suppress(Literal(r"\right"))
- + (rightDelim | ambiDelim)
+ + ((rightDelim | ambiDelim) | Error("Expected a delimiter"))
 )
 
 math = OneOrMore(
@@ -2007,7 +2016,8 @@
 + ZeroOrMore(
 Suppress(math_delim)
 + math
- + Suppress(math_delim)
+ + (Suppress(math_delim)
+ | Error("Expected end of math '$'"))
 + non_math
 ) 
 ) + StringEnd()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年09月07日 20:28:04
Revision: 3815
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3815&view=rev
Author: mdboom
Date: 2007年09月07日 13:28:01 -0700 (2007年9月07日)
Log Message:
-----------
Support characters composed of multiple characters. Only one
supported at the moment is AA (angstrom).
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年09月07日 19:45:48 UTC (rev 3814)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年09月07日 20:28:01 UTC (rev 3815)
@@ -153,13 +153,6 @@
 ####################
 
 
-# a character over another character
-charOverChars = {
- # The first 2 entires in the tuple are (font, char, sizescale) for
- # the two symbols under and over. The third entry is the space
- # between the two symbols in points
- r'\angstrom' : ( ('rm', 'A', 1.0), (None, '\circ', 0.5), 0.0 ),
- }
 
 ##############################################################################
 # FONTS
@@ -1771,7 +1764,7 @@
 
 def Error(msg):
 def raise_error(s, loc, toks):
- raise ParseFatalException(msg)
+ raise ParseFatalException(msg + "\n" + s)
 
 empty = Empty()
 empty.setParseAction(raise_error)
@@ -1854,8 +1847,7 @@
 
 bslash = Literal('\\')
 
- accent = oneOf("hat check dot breve acute ddot grave tilde bar "
- "vec \" ` ' ~ . ^ widehat widetilde")
+ 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 "
@@ -1890,8 +1882,13 @@
 )
 ).setParseAction(self.symbol).leaveWhitespace()
 
+ c_over_c =(Suppress(bslash)
+ + oneOf(self._char_over_chars.keys())
+ ).setParseAction(self.char_over_chars)
+ 
 accent = Group(
- Combine(bslash + accent)
+ Suppress(bslash)
+ + accent
 + placeable
 ).setParseAction(self.accent).setName("accent")
 
@@ -1930,7 +1927,7 @@
 Suppress(Literal("["))
 + Group(
 OneOrMore(
- symbol
+ (c_over_c | symbol)
 ^ font
 )
 )
@@ -1942,7 +1939,7 @@
 
 placeable <<(accent
 ^ function
- ^ symbol
+ ^ (c_over_c | symbol)
 ^ group
 ^ frac
 ^ sqrt
@@ -2120,25 +2117,69 @@
 do_kern = False)]
 return [char]
 
+ _char_over_chars = {
+ # The first 2 entires in the tuple are (font, char, sizescale) for
+ # the two symbols under and over. The third element is the space
+ # (in multiples of underline height)
+ r'AA' : ( ('rm', 'A', 1.0), (None, '\circ', 0.5), 0.0),
+ }
+ 
+ def char_over_chars(self, s, loc, toks):
+ sym = toks[0]
+ state = self.get_state()
+ thickness = state.font_output.get_underline_thickness(
+ state.font, state.fontsize, state.dpi)
+
+ under_desc, over_desc, space = \
+ self._char_over_chars.get(sym, (None, None, 0.0))
+ if under_desc is None:
+ raise ParseFatalException("Error parsing symbol")
+ 
+ over_state = state.copy()
+ if over_desc[0] is not None:
+ over_state.font = over_desc[0]
+ over_state.fontsize *= over_desc[2]
+ over = Accent(over_desc[1], over_state)
+
+ under_state = state.copy()
+ if under_desc[0] is not None:
+ under_state.font = under_desc[0]
+ under_state.fontsize *= under_desc[2]
+ under = Char(under_desc[1], under_state)
+
+ width = max(over.width, under.width)
+ 
+ over_centered = HCentered([over])
+ over_centered.hpack(width, 'exactly')
+
+ under_centered = HCentered([under])
+ under_centered.hpack(width, 'exactly')
+ 
+ return Vlist([
+ over_centered,
+ Vbox(0., thickness * space),
+ under_centered
+ ])
+ 
 _accent_map = {
- r'\hat' : r'\circumflexaccent',
- r'\breve' : r'\combiningbreve',
- r'\bar' : r'\combiningoverline',
- r'\grave' : r'\combininggraveaccent',
- r'\acute' : r'\combiningacuteaccent',
- r'\ddot' : r'\combiningdiaeresis',
- r'\tilde' : r'\combiningtilde',
- r'\dot' : r'\combiningdotabove',
- r'\vec' : r'\combiningrightarrowabove',
- r'\"' : r'\combiningdiaeresis',
- r"\`" : r'\combininggraveaccent',
- r"\'" : r'\combiningacuteaccent',
- r'\~' : r'\combiningtilde',
- r'\.' : r'\combiningdotabove',
- r'\^' : r'\circumflexaccent'
+ r'hat' : r'\circumflexaccent',
+ r'breve' : r'\combiningbreve',
+ r'bar' : r'\combiningoverline',
+ r'grave' : r'\combininggraveaccent',
+ r'acute' : r'\combiningacuteaccent',
+ r'ddot' : r'\combiningdiaeresis',
+ r'tilde' : r'\combiningtilde',
+ r'dot' : r'\combiningdotabove',
+ r'vec' : r'\combiningrightarrowabove',
+ r'"' : r'\combiningdiaeresis',
+ r"`" : r'\combininggraveaccent',
+ r"'" : r'\combiningacuteaccent',
+ r'~' : r'\combiningtilde',
+ r'.' : r'\combiningdotabove',
+ r'^' : r'\circumflexaccent'
 }
 
- _wide_accents = Set(r"\widehat \widetilde".split())
+ _wide_accents = Set(r"widehat widetilde".split())
 
 def accent(self, s, loc, toks):
 assert(len(toks)==1)
@@ -2150,7 +2191,7 @@
 accent, sym = toks[0]
 if accent in self._wide_accents:
 accent = AutoWidthChar(
- accent, sym.width, state, char_class=Accent)
+ '\\' + accent, sym.width, state, char_class=Accent)
 else:
 accent = Accent(self._accent_map[accent], state)
 centered = HCentered([accent])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年11月06日 19:39:42
Revision: 4132
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4132&view=rev
Author: mdboom
Date: 2007年11月06日 11:39:23 -0800 (2007年11月06日)
Log Message:
-----------
Converted STIX fonts from otf to ttf.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月06日 19:38:57 UTC (rev 4131)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月06日 19:39:23 UTC (rev 4132)
@@ -835,21 +835,21 @@
 return [(fontname, sym)]
 
 class StixFonts(UnicodeFonts):
- _fontmap = { 'rm' : ('STIXGeneral', 'otf'),
- 'tt' : ('VeraMono', 'ttf'),
- 'it' : ('STIXGeneralItalic', 'otf'),
- 'bf' : ('STIXGeneralBol', 'otf'),
- 'sf' : ('Vera', 'ttf'),
- 'nonunirm' : ('STIXNonUni', 'otf'),
- 'nonuniit' : ('STIXNonUniIta', 'otf'),
- 'nonunibf' : ('STIXNonUniBol', 'otf'),
+ _fontmap = { 'rm' : 'STIXGeneral',
+ 'tt' : 'VeraMono',
+ 'it' : 'STIXGeneralItalic',
+ 'bf' : 'STIXGeneralBol',
+ 'sf' : 'Vera',
+ 'nonunirm' : 'STIXNonUni',
+ 'nonuniit' : 'STIXNonUniIta',
+ 'nonunibf' : 'STIXNonUniBol',
 
- 0 : ('STIXGeneral', 'otf'),
- 1 : ('STIXSiz1Sym', 'otf'),
- 2 : ('STIXSiz2Sym', 'otf'),
- 3 : ('STIXSiz3Sym', 'otf'),
- 4 : ('STIXSiz4Sym', 'otf'),
- 5 : ('STIXSiz5Sym', 'otf')
+ 0 : 'STIXGeneral',
+ 1 : 'STIXSiz1Sym',
+ 2 : 'STIXSiz2Sym',
+ 3 : 'STIXSiz3Sym',
+ 4 : 'STIXSiz4Sym',
+ 5 : 'STIXSiz5Sym'
 }
 fontmap = {}
 use_cmex = False
@@ -858,8 +858,8 @@
 def __init__(self, *args, **kwargs):
 TruetypeFonts.__init__(self, *args, **kwargs)
 if not len(self.fontmap):
- for key, (name, ext) in self._fontmap.iteritems():
- fullpath = os.path.join(self.basepath, ext, name + "." + ext)
+ for key, name in self._fontmap.iteritems():
+ fullpath = os.path.join(self.basepath, 'ttf', name + ".ttf")
 self.fontmap[key] = fullpath
 self.fontmap[name] = fullpath
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年11月08日 14:31:19
Revision: 4160
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4160&view=rev
Author: mdboom
Date: 2007年11月08日 06:31:15 -0800 (2007年11月08日)
Log Message:
-----------
Throw in dummy characters for symbols not in the Bakoma fonts.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月08日 14:06:25 UTC (rev 4159)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月08日 14:31:15 UTC (rev 4160)
@@ -672,6 +672,7 @@
 _slanted_symbols = Set(r"\int \oint".split())
 
 def _get_glyph(self, fontname, sym, fontsize):
+ symbol_name = None
 if fontname in self.fontmap and latex_to_bakoma.has_key(sym):
 basename, num = latex_to_bakoma[sym]
 slanted = (basename == "cmmi10") or sym in self._slanted_symbols
@@ -682,11 +683,21 @@
 slanted = (fontname == "it")
 cached_font = self._get_font(fontname)
 num = ord(sym)
- symbol_name = cached_font.font.get_glyph_name(
- cached_font.charmap[num])
- else:
- raise ValueError('unrecognized symbol "%s"' % sym)
+ gid = cached_font.charmap.get(num)
+ if gid is not None:
+ symbol_name = cached_font.font.get_glyph_name(
+ cached_font.charmap[num])
 
+ if symbol_name is None:
+ warn("Unrecognized symbol '%s'. Substituting with a dummy symbol."
+ % sym.encode('ascii', 'backslashreplace'), MathTextWarning)
+ fontname = 'it'
+ cached_font = self._get_font(fontname)
+ num = 0x3F # currency character, for lack of anything better
+ gid = cached_font.charmap[num]
+ symbol_name = cached_font.font.get_glyph_name(gid)
+ slanted = False
+
 return cached_font, num, symbol_name, fontsize, slanted
 
 # The Bakoma fonts contain many pre-sized alternatives for the
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年11月20日 17:43:48
Revision: 4394
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4394&view=rev
Author: mdboom
Date: 2007年11月20日 09:43:40 -0800 (2007年11月20日)
Log Message:
-----------
Minor refactorings, comments, and one bugfix (to do with the alignment
of wide accents with STIX fonts).
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月20日 14:52:24 UTC (rev 4393)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月20日 17:43:40 UTC (rev 4394)
@@ -1709,6 +1709,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.
@@ -1744,11 +1745,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:
@@ -1787,14 +1791,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):
@@ -1807,9 +1809,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:
@@ -1842,14 +1847,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
@@ -1923,6 +1926,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")
@@ -1946,15 +1964,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'\ ')
@@ -1993,7 +2006,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
@@ -2065,11 +2079,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(
@@ -2397,7 +2409,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(
@@ -2405,6 +2419,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.
@@ -2433,6 +2448,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.
From: <md...@us...> - 2007年11月21日 16:18:56
Revision: 4405
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4405&view=rev
Author: mdboom
Date: 2007年11月21日 08:18:52 -0800 (2007年11月21日)
Log Message:
-----------
Fix mathtext bug.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月21日 16:05:18 UTC (rev 4404)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月21日 16:18:52 UTC (rev 4405)
@@ -2079,9 +2079,9 @@
 | placeable
 )
 
- ambiDelim = oneOf(self._ambiDelim)
- leftDelim = oneOf(self._leftDelim)
- rightDelim = oneOf(self._rightDelim)
+ ambiDelim = oneOf(list(self._ambiDelim))
+ leftDelim = oneOf(list(self._leftDelim))
+ rightDelim = oneOf(list(self._rightDelim))
 autoDelim <<(Suppress(Literal(r"\left"))
 + ((leftDelim | ambiDelim) | Error("Expected a delimiter"))
 + Group(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年11月21日 16:35:39
Revision: 4407
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4407&view=rev
Author: mdboom
Date: 2007年11月21日 08:35:38 -0800 (2007年11月21日)
Log Message:
-----------
Mathtext speed improvement.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月21日 16:25:31 UTC (rev 4406)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月21日 16:35:38 UTC (rev 4407)
@@ -505,6 +505,7 @@
 (through ft2font)
 """
 basepath = os.path.join( get_data_path(), 'fonts' )
+ _fonts = {}
 
 class CachedFont:
 def __init__(self, font):
@@ -519,21 +520,17 @@
 def __init__(self, default_font_prop, mathtext_backend):
 Fonts.__init__(self, default_font_prop, mathtext_backend)
 self.glyphd = {}
- self.fonts = {}
 
- filename = findfont(default_font_prop)
- default_font = self.CachedFont(FT2Font(str(filename)))
+ if self._fonts == {}:
+ filename = findfont(default_font_prop)
+ default_font = self.CachedFont(FT2Font(str(filename)))
 
- self.fonts['default'] = default_font
+ self._fonts['default'] = default_font
 
 def destroy(self):
 self.glyphd = None
- for cached_font in self.fonts.values():
- cached_font.charmap = None
- cached_font.glyphmap = None
- cached_font.font = None
 Fonts.destroy(self)
- 
+
 def _get_font(self, font):
 """Looks up a CachedFont with its charmap and inverse charmap.
 font may be a TeX font name (cal, rm, it etc.), or postscript name."""
@@ -542,16 +539,16 @@
 else:
 basename = font
 
- cached_font = self.fonts.get(basename)
+ cached_font = self._fonts.get(basename)
 if cached_font is None:
 try:
 font = FT2Font(basename)
 except RuntimeError:
 return None
 cached_font = self.CachedFont(font)
- self.fonts[basename] = cached_font
- self.fonts[font.postscript_name] = cached_font
- self.fonts[font.postscript_name.lower()] = cached_font
+ self._fonts[basename] = cached_font
+ self._fonts[font.postscript_name] = cached_font
+ self._fonts[font.postscript_name.lower()] = cached_font
 return cached_font
 
 def _get_offset(self, cached_font, glyph, fontsize, dpi):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年11月26日 14:29:52
Revision: 4438
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4438&view=rev
Author: mdboom
Date: 2007年11月26日 06:29:49 -0800 (2007年11月26日)
Log Message:
-----------
Minor speed improvements in mathtext. Removing trailing whitespace.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月26日 14:10:11 UTC (rev 4437)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月26日 14:29:49 UTC (rev 4438)
@@ -210,7 +210,7 @@
 class MathtextBackendBbox(MathtextBackend):
 """A backend whose only purpose is to get a precise bounding box.
 Only required for the Agg backend."""
- 
+
 def __init__(self, real_backend):
 MathtextBackend.__init__(self)
 self.bbox = [0, 0, 0, 0]
@@ -221,7 +221,7 @@
 min(self.bbox[1], y1),
 max(self.bbox[2], x2),
 max(self.bbox[3], y2)]
- 
+
 def render_glyph(self, ox, oy, info):
 self._update_bbox(ox + info.metrics.xmin,
 oy - info.metrics.ymax,
@@ -253,14 +253,14 @@
 self.real_backend.fonts_object = self.fonts_object
 self.real_backend.ox = self.bbox[0]
 self.real_backend.oy = self.bbox[1]
- 
+
 class MathtextBackendAggRender(MathtextBackend):
 def __init__(self):
 self.ox = 0
 self.oy = 0
 self.image = None
 MathtextBackend.__init__(self)
- 
+
 def set_canvas_size(self, w, h, d):
 MathtextBackend.set_canvas_size(self, w, h, d)
 self.image = FT2Image(ceil(w), ceil(h + d))
@@ -286,11 +286,11 @@
 
 def MathtextBackendAgg():
 return MathtextBackendBbox(MathtextBackendAggRender())
- 
+
 class MathtextBackendBitmapRender(MathtextBackendAggRender):
 def get_results(self, box):
 return self.image
- 
+
 def MathtextBackendBitmap():
 return MathtextBackendBbox(MathtextBackendBitmapRender())
 
@@ -312,7 +312,7 @@
 """ % locals()
 self.lastfont = postscript_name, fontsize
 self.pswriter.write(ps)
- 
+
 ps = """%(ox)f %(oy)f moveto
 /%(symbol_name)s glyphshow\n
 """ % locals()
@@ -428,7 +428,7 @@
 """Fix any cyclical references before the object is about
 to be destroyed."""
 self.used_characters = None
- 
+
 def get_kern(self, font1, sym1, fontsize1,
 font2, sym2, fontsize2, dpi):
 """
@@ -739,7 +739,7 @@
 
 fontmap = {}
 use_cmex = True
- 
+
 def __init__(self, *args, **kwargs):
 # This must come first so the backend's owner is set correctly
 if rcParams['mathtext.fallback_to_cm']:
@@ -760,7 +760,7 @@
 
 def _map_virtual_font(self, fontname, font_class, uniindex):
 return fontname, uniindex
- 
+
 def _get_glyph(self, fontname, font_class, sym, fontsize):
 found_symbol = False
 
@@ -769,7 +769,7 @@
 if uniindex is not None:
 fontname = 'ex'
 found_symbol = True
- 
+
 if not found_symbol:
 try:
 uniindex = get_unicode_index(sym)
@@ -782,7 +782,7 @@
 
 fontname, uniindex = self._map_virtual_font(
 fontname, font_class, uniindex)
- 
+
 # Only characters in the "Letter" class should be italicized in 'it'
 # mode. Greek capital letters should be Roman.
 if found_symbol:
@@ -832,13 +832,16 @@
 return [(fontname, sym)]
 
 class StixFonts(UnicodeFonts):
+ """
+ A font handling class for the STIX fonts
+ """
 _fontmap = { 'rm' : 'STIXGeneral',
 'it' : 'STIXGeneralItalic',
 'bf' : 'STIXGeneralBol',
 'nonunirm' : 'STIXNonUni',
 'nonuniit' : 'STIXNonUniIta',
 'nonunibf' : 'STIXNonUniBol',
- 
+
 0 : 'STIXGeneral',
 1 : 'STIXSiz1Sym',
 2 : 'STIXSiz2Sym',
@@ -851,7 +854,6 @@
 cm_fallback = False
 
 def __init__(self, *args, **kwargs):
- self._sans = kwargs.pop("sans", False)
 TruetypeFonts.__init__(self, *args, **kwargs)
 if not len(self.fontmap):
 for key, name in self._fontmap.iteritems():
@@ -893,14 +895,14 @@
 # This will generate a dummy character
 uniindex = 0x1
 fontname = 'it'
- 
+
 # Handle private use area glyphs
 if (fontname in ('it', 'rm', 'bf') and
 uniindex >= 0xe000 and uniindex <= 0xf8ff):
 fontname = 'nonuni' + fontname
 
 return fontname, uniindex
- 
+
 _size_alternatives = {}
 def get_sized_alternatives_for_symbol(self, fontname, sym):
 alternatives = self._size_alternatives.get(sym)
@@ -921,7 +923,14 @@
 
 self._size_alternatives[sym] = alternatives
 return alternatives
- 
+
+class StixSansFonts(StixFonts):
+ """
+ A font handling class for the STIX fonts (using sans-serif
+ characters by default).
+ """
+ _sans = True
+
 class StandardPsFonts(Fonts):
 """
 Use the standard postscript fonts for rendering to backend_ps
@@ -1087,7 +1096,8 @@
 # Note that (as TeX) y increases downward, unlike many other parts of
 # matplotlib.
 
-# How much text shrinks when going to the next-smallest level
+# How much text shrinks when going to the next-smallest level. GROW_FACTOR
+# must be the inverse of SHRINK_FACTOR.
 SHRINK_FACTOR = 0.7
 GROW_FACTOR = 1.0 / SHRINK_FACTOR
 # The number of different sizes of chars to use, beyond which they will not
@@ -1162,10 +1172,16 @@
 pass
 
 class Vbox(Box):
+ """
+ A box with only height (zero width).
+ """
 def __init__(self, height, depth):
 Box.__init__(self, 0., height, depth)
 
 class Hbox(Box):
+ """
+ A box with only width (zero height and depth).
+ """
 def __init__(self, width):
 Box.__init__(self, width, 0., 0.)
 
@@ -1243,8 +1259,9 @@
 self.depth *= GROW_FACTOR
 
 class Accent(Char):
- """The font metrics need to be dealt with differently for accents, since they
- are already offset correctly from the baseline in TrueType fonts."""
+ """The font metrics need to be dealt with differently for accents,
+ since they are already offset correctly from the baseline in
+ TrueType fonts."""
 def _update_metrics(self):
 metrics = self._metrics = self.font_output.get_metrics(
 self.font, self.font_class, self.c, self.fontsize, self.dpi)
@@ -1743,7 +1760,7 @@
 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)
@@ -1866,7 +1883,7 @@
 empty = Empty()
 empty.setParseAction(raise_error)
 return empty
- 
+
 class Parser(object):
 _binary_operators = Set(r'''
 + *
@@ -1924,7 +1941,7 @@
 _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
@@ -1937,7 +1954,7 @@
 _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")
@@ -1949,7 +1966,7 @@
 self._expression = Forward().setParseAction(self.finish).setName("finish")
 
 float = Regex(r"-?[0-9]+\.?[0-9]*")
- 
+
 lbrace = Literal('{').suppress()
 rbrace = Literal('}').suppress()
 start_group = (Optional(latexfont) + lbrace)
@@ -1995,7 +2012,7 @@
 c_over_c =(Suppress(bslash)
 + oneOf(self._char_over_chars.keys())
 ).setParseAction(self.char_over_chars)
- 
+
 accent = Group(
 Suppress(bslash)
 + accent
@@ -2057,7 +2074,7 @@
 ) | Error("Expected symbol or group")
 
 simple <<(space
- | customspace 
+ | customspace
 | font
 | subsuper
 )
@@ -2107,11 +2124,11 @@
 + (Suppress(math_delim)
 | Error("Expected end of math '$'"))
 + non_math
- ) 
+ )
 ) + StringEnd()
 
 self._expression.enablePackrat()
- 
+
 self.clear()
 
 def clear(self):
@@ -2158,7 +2175,7 @@
 self.font_class = name
 self._font = name
 font = property(_get_font, _set_font)
- 
+
 def get_state(self):
 return self._state_stack[-1]
 
@@ -2216,7 +2233,7 @@
 
 def customspace(self, s, loc, toks):
 return [self._make_space(float(toks[1]))]
- 
+
 def symbol(self, s, loc, toks):
 # print "symbol", toks
 c = toks[0]
@@ -2242,7 +2259,7 @@
 # (in multiples of underline height)
 r'AA' : ( ('rm', 'A', 1.0), (None, '\circ', 0.5), 0.0),
 }
- 
+
 def char_over_chars(self, s, loc, toks):
 sym = toks[0]
 state = self.get_state()
@@ -2253,7 +2270,7 @@
 self._char_over_chars.get(sym, (None, None, 0.0))
 if under_desc is None:
 raise ParseFatalException("Error parsing symbol")
- 
+
 over_state = state.copy()
 if over_desc[0] is not None:
 over_state.font = over_desc[0]
@@ -2267,19 +2284,19 @@
 under = Char(under_desc[1], under_state)
 
 width = max(over.width, under.width)
- 
+
 over_centered = HCentered([over])
 over_centered.hpack(width, 'exactly')
 
 under_centered = HCentered([under])
 under_centered.hpack(width, 'exactly')
- 
+
 return Vlist([
 over_centered,
 Vbox(0., thickness * space),
 under_centered
 ])
- 
+
 _accent_map = {
 r'hat' : r'\circumflexaccent',
 r'breve' : r'\combiningbreve',
@@ -2603,7 +2620,7 @@
 return is width, height, fonts
 """
 _parser = None
- 
+
 _backend_mapping = {
 'Bitmap': MathtextBackendBitmap,
 'Agg' : MathtextBackendAgg,
@@ -2613,6 +2630,13 @@
 'Cairo' : MathtextBackendCairo
 }
 
+ _font_type_mapping = {
+ 'cm' : BakomaFonts,
+ 'stix' : StixFonts,
+ 'stixsans' : StixSansFonts,
+ 'custom' : UnicodeFonts
+ }
+
 def __init__(self, output):
 self._output = output
 self._cache = {}
@@ -2620,7 +2644,7 @@
 def parse(self, s, dpi = 72, prop = None):
 if prop is None:
 prop = FontProperties()
- 
+
 cacheKey = (s, dpi, hash(prop))
 result = self._cache.get(cacheKey)
 if result is not None:
@@ -2631,16 +2655,13 @@
 else:
 backend = self._backend_mapping[self._output]()
 fontset = rcParams['mathtext.fontset']
- if fontset == 'cm':
- font_output = BakomaFonts(prop, backend)
- elif fontset == 'stix':
- font_output = StixFonts(prop, backend)
- elif fontset == 'stixsans':
- font_output = StixFonts(prop, backend, sans=True)
- elif fontset == 'custom':
- font_output = UnicodeFonts(prop, backend)
+ fontset_class = self._font_type_mapping.get(fontset)
+ if fontset_class is not None:
+ font_output = fontset_class(prop, backend)
 else:
- raise ValueError("mathtext.fontset must be either 'cm', 'stix', 'stixsans', or 'custom'")
+ raise ValueError(
+ "mathtext.fontset must be either 'cm', 'stix', "
+ "'stixsans', or 'custom'")
 
 fontsize = prop.get_size_in_points()
 
@@ -2648,7 +2669,7 @@
 # with each request.
 if self._parser is None:
 self.__class__._parser = Parser()
- 
+
 box = self._parser.parse(s, font_output, fontsize, dpi)
 font_output.set_canvas_size(box.width, box.height, box.depth)
 result = font_output.get_results(box)
@@ -2660,5 +2681,5 @@
 font_output.destroy()
 font_output.mathtext_backend.fonts_object = None
 font_output.mathtext_backend = None
- 
+
 return result
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年11月28日 20:13:51
Revision: 4492
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4492&view=rev
Author: mdboom
Date: 2007年11月28日 12:13:47 -0800 (2007年11月28日)
Log Message:
-----------
Fix bug using stix fonts.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月28日 18:30:10 UTC (rev 4491)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年11月28日 20:13:47 UTC (rev 4492)
@@ -852,6 +852,7 @@
 fontmap = {}
 use_cmex = False
 cm_fallback = False
+ _sans = False
 
 def __init__(self, *args, **kwargs):
 TruetypeFonts.__init__(self, *args, **kwargs)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年12月03日 13:20:29
Revision: 4557
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4557&view=rev
Author: mdboom
Date: 2007年12月03日 05:20:19 -0800 (2007年12月03日)
Log Message:
-----------
Fix missing font file error.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年12月03日 08:22:16 UTC (rev 4556)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年12月03日 13:20:19 UTC (rev 4557)
@@ -16,8 +16,19 @@
 
 s = r'$\mathcal{R}\prod_{i=\alpha\mathcal{B}}^\infty a_i\sin(2 \pi f x_i)$'
 
- The fonts \cal, \rm, \it, and \tt are allowed.
+ Different fonts may be selected:
+ \mathcal Calligraphic fonts
+ \mathrm Roman (upright) font
+ \mathit Italic font
+ \mathtt Typewriter (monospaced) font, similar to Courier
 
+ Additionally, if using the STIX fonts:
+ \mathbb Blackboard (double-struck) font
+ \mathcircled Circled characters
+ \mathfrak Fraktur (Gothic-style) font
+ \mathscr Script (cursive) font
+ \mathsf Sans-serif font
+
 The following accents are provided: \hat, \breve, \grave, \bar,
 \acute, \tilde, \vec, \dot, \ddot. All of them have the same
 syntax, eg to make an overbar you do \bar{o} or to make an o umlaut
@@ -541,10 +552,7 @@
 
 cached_font = self._fonts.get(basename)
 if cached_font is None:
- try:
- font = FT2Font(basename)
- except RuntimeError:
- return None
+ font = FT2Font(basename)
 cached_font = self.CachedFont(font)
 self._fonts[basename] = cached_font
 self._fonts[font.postscript_name] = cached_font
@@ -652,13 +660,20 @@
 if fontname in self.fontmap and latex_to_bakoma.has_key(sym):
 basename, num = latex_to_bakoma[sym]
 slanted = (basename == "cmmi10") or sym in self._slanted_symbols
- cached_font = self._get_font(basename)
- symbol_name = cached_font.font.get_glyph_name(num)
- num = cached_font.glyphmap[num]
+ try:
+ cached_font = self._get_font(basename)
+ except RuntimeError:
+ pass
+ else:
+ symbol_name = cached_font.font.get_glyph_name(num)
+ num = cached_font.glyphmap[num]
 elif len(sym) == 1:
 slanted = (fontname == "it")
- cached_font = self._get_font(fontname)
- if cached_font is not None:
+ try:
+ cached_font = self._get_font(fontname)
+ except RuntimeError:
+ pass
+ else:
 num = ord(sym)
 gid = cached_font.charmap.get(num)
 if gid is not None:
@@ -795,9 +810,12 @@
 new_fontname = 'rm'
 
 slanted = (new_fontname == 'it') or sym in self._slanted_symbols
- cached_font = self._get_font(new_fontname)
 found_symbol = False
- if cached_font is not None:
+ try:
+ cached_font = self._get_font(new_fontname)
+ except RuntimeError:
+ pass
+ else:
 try:
 glyphindex = cached_font.charmap[uniindex]
 found_symbol = True
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年12月18日 20:57:50
Revision: 4769
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4769&view=rev
Author: mdboom
Date: 2007年12月18日 12:57:40 -0800 (2007年12月18日)
Log Message:
-----------
Update list of supported math symbols.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年12月18日 19:17:13 UTC (rev 4768)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年12月18日 20:57:40 UTC (rev 4769)
@@ -81,35 +81,81 @@
 
 Allowed TeX symbols:
 
- [MGDTODO: This list is no longer exhaustive and needs to be updated]
+ $ \% \AA \AE \BbbC \BbbN \BbbP \BbbQ \BbbR \BbbZ \Bumpeq \Cap \Colon
+ \Cup \Delta \Doteq \Downarrow \Equiv \Finv \Gamma \H \Im \L \Lambda
+ \Ldsh \Leftarrow \Leftrightarrow \Lleftarrow \Lsh \Nearrow \Nwarrow
+ \O \OE \Omega \P \Phi \Pi \Psi \Rdsh \Re \Rightarrow \Rrightarrow
+ \Rsh \S \Searrow \Sigma \Subset \Supset \Swarrow \Theta \Uparrow
+ \Updownarrow \Upsilon \Vdash \Vert \Vvdash \Xi \_ \__sqrt__ \ac
+ \acute \acwopencirclearrow \adots \ae \aleph \alpha \angle \approx
+ \approxeq \approxident \arceq \ast \asymp \backcong \backprime
+ \backsim \backsimeq \backslash \bar \barleftarrow \barwedge \because
+ \beta \beth \between \bigcap \bigcirc \bigcup \bigodot \bigoplus
+ \bigotimes \bigstar \bigtriangledown \bigtriangleup \biguplus
+ \bigvee \bigwedge \blacksquare \blacktriangle \blacktriangledown
+ \blacktriangleleft \blacktriangleright \bot \bowtie \boxbar \boxdot
+ \boxminus \boxplus \boxtimes \breve \bullet \bumpeq \c \candra \cap
+ \carriagereturn \cdot \cdotp \cdots \check \checkmark \chi \circ
+ \circeq \circledR \circledS \circledast \circledcirc \circleddash
+ \circumflexaccent \clubsuit \clubsuitopen \colon \coloneq
+ \combiningacuteaccent \combiningbreve \combiningdiaeresis
+ \combiningdotabove \combininggraveaccent \combiningoverline
+ \combiningrightarrowabove \combiningtilde \complement \cong \coprod
+ \copyright \cup \cupdot \curlyeqprec \curlyeqsucc \curlyvee
+ \curlywedge \curvearrowleft \curvearrowright \cwopencirclearrow \d
+ \dag \daleth \danger \dashv \ddag \ddddot \dddot \ddot \ddots
+ \degree \delta \diamond \diamondsuit \digamma \div \divideontimes
+ \dot \doteq \dotminus \dotplus \dots \doublebarwedge ? \downarrow
+ \downdownarrows \downharpoonleft \downharpoonright \downzigzagarrow
+ \ell \emdash \emptyset \endash \enspace \epsilon \eqcirc \eqcolon
+ \eqdef \eqgtr \eqless \eqsim \equiv \eta \eth \exists \fallingdotseq
+ \flat \forall \frakC \frakZ \frown \gamma \geq \geqq \gg \ggg \gimel
+ \gneqq \gnsim \grave \greater \gtrdot \gtreqless \gtrless \gtrsim
+ \hat \heartsuit \hookleftarrow \hookrightarrow \i \iiint \iint
+ \imageof \imath \in \infty \int \intercal \invnot \iota \jmath \k
+ \kappa \kernelcontraction \l \lambda \lambdabar \lasp \lbrace
+ \lbrack \lceil \leftangle \leftarrow \leftarrowtail \leftbrace
+ \leftharpoonaccent \leftharpoondown \leftharpoonup \leftleftarrows
+ \leftparen \leftrightarrow \leftrightarrows \leftrightharpoons
+ \leftthreetimes \leq \leqq \less \lessdot \lesseqgtr \lessgtr
+ \lesssim \lfloor \ll \llcorner \lll \lneqq \lnsim \looparrowleft
+ \looparrowright \lq \lrcorner \ltimes \maltese \mapsdown \mapsfrom
+ \mapsto \mapsup \measeq \measuredangle \mho \mid \minus \models \mp
+ \mu \multimap \nLeftarrow \nLeftrightarrow \nRightarrow \nVDash
+ \nVdash \nabla \napprox \natural \ncong \ne \nearrow \neg \nequiv
+ \nexists \ngeq \ngtr \ni \nleftarrow \nleftrightarrow \nleq \nless
+ \nmid \not \notin \nparallel \nprec \nrightarrow \nsim \nsime
+ \nsubset \nsubseteq \nsucc \nsupset \nsupseteq \ntriangleleft
+ \ntrianglelefteq \ntriangleright \ntrianglerighteq \nu \nvDash
+ \nvdash \nwarrow \o \obar \ocirc \odot \oe \oiiint \oiint \oint
+ \omega \ominus \oplus \origof \oslash \otimes \overarc
+ \overleftarrow \overleftrightarrow \parallel \partial \phi \pi
+ \pitchfork \pm \prec \preccurlyeq \preceq \precnsim \precsim \prime
+ \prod \propto \prurel \psi \quad \questeq \rasp \rbrace \rbrack
+ \rceil \rfloor \rho \rightangle \rightarrow \rightarrowbar
+ \rightarrowtail \rightbrace \rightharpoonaccent \rightharpoondown
+ \rightharpoonup \rightleftarrows \rightleftharpoons \rightparen
+ \rightrightarrows \rightthreetimes \rightzigzagarrow \risingdotseq
+ \rq \rtimes \scrB \scrE \scrF \scrH \scrI \scrL \scrM \scrR \scre
+ \scrg \scro \scurel \searrow \sharp \sigma \sim \simeq \slash
+ \smallsetminus \smile \solbar \spadesuit \spadesuitopen
+ \sphericalangle \sqcap \sqcup \sqsubset \sqsubseteq \sqsupset
+ \sqsupseteq \ss \star \stareq \sterling \subset \subseteq \subsetneq
+ \succ \succcurlyeq \succeq \succnsim \succsim \sum \supset \supseteq
+ \supsetneq \swarrow \t \tau \textasciiacute \textasciicircum
+ \textasciigrave \textasciitilde \textexclamdown \textquestiondown
+ \textquotedblleft \textquotedblright \therefore \theta \thickspace
+ \thinspace \tilde \times \to \top \triangledown \triangleleft
+ \trianglelefteq \triangleq \triangleright \trianglerighteq
+ \turnednot \twoheaddownarrow \twoheadleftarrow \twoheadrightarrow
+ \twoheaduparrow \ulcorner \underbar \uparrow \updownarrow
+ \updownarrowbar \updownarrows \upharpoonleft \upharpoonright \uplus
+ \upsilon \upuparrows \urcorner \vDash \varepsilon \varkappa
+ \varnothing \varphi \varpi \varrho \varsigma \vartheta \vartriangle
+ \vartriangleleft \vartriangleright \vdash \vdots \vec \vee \veebar
+ \veeeq \vert \wedge \wedgeq \widehat \widetilde \wp \wr \xi \yen
+ \zeta \{ \| \}
 
- \/ \Delta \Downarrow \Gamma \Im \LEFTangle \LEFTbrace \LEFTbracket
- \LEFTparen \Lambda \Leftarrow \Leftbrace \Leftbracket \Leftparen
- \Leftrightarrow \Omega \P \Phi \Pi \Psi \RIGHTangle \RIGHTbrace
- \RIGHTbracket \RIGHTparen \Re \Rightarrow \Rightbrace \Rightbracket
- \Rightparen \S \SQRT \Sigma \Sqrt \Theta \Uparrow \Updownarrow
- \Upsilon \Vert \Xi \aleph \alpha \approx \angstrom \ast \asymp
- \backslash \beta \bigcap \bigcirc \bigcup \bigodot \bigoplus
- \bigotimes \bigtriangledown \bigtriangleup \biguplus \bigvee
- \bigwedge \bot \bullet \cap \cdot \chi \circ \clubsuit \coprod \cup
- \dag \dashv \ddag \delta \diamond \diamondsuit \div \downarrow \ell
- \emptyset \epsilon \equiv \eta \exists \flat \forall \frown \gamma
- \geq \gg \heartsuit \hspace \imath \in \infty \int \iota \jmath
- \kappa \lambda \langle \lbrace \lceil \leftangle \leftarrow
- \leftbrace \leftbracket \leftharpoondown \leftharpoonup \leftparen
- \leftrightarrow \leq \lfloor \ll \mid \mp \mu \nabla \natural
- \nearrow \neg \ni \nu \nwarrow \odot \oint \omega \ominus \oplus
- \oslash \otimes \phi \pi \pm \prec \preceq \prime \prod \propto \psi
- \rangle \rbrace \rceil \rfloor \rho \rightangle \rightarrow
- \rightbrace \rightbracket \rightharpoondown \rightharpoonup
- \rightparen \searrow \sharp \sigma \sim \simeq \slash \smile
- \spadesuit \sqcap \sqcup \sqrt \sqsubseteq \sqsupseteq \subset
- \subseteq \succ \succeq \sum \supset \supseteq \swarrow \tau \theta
- \times \top \triangleleft \triangleright \uparrow \updownarrow
- \uplus \upsilon \varepsilon \varphi \varphi \varrho \varsigma
- \vartheta \vdash \vee \vert \wedge \wp \wr \xi \zeta
-
-
 BACKENDS
 
 mathtext currently works with GTK, Agg, GTKAgg, TkAgg and WxAgg and
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年12月18日 21:00:05
Revision: 4770
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4770&view=rev
Author: mdboom
Date: 2007年12月18日 12:59:56 -0800 (2007年12月18日)
Log Message:
-----------
Update list of supported backends.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2007年12月18日 20:57:40 UTC (rev 4769)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2007年12月18日 20:59:56 UTC (rev 4770)
@@ -158,17 +158,8 @@
 
 BACKENDS
 
- mathtext currently works with GTK, Agg, GTKAgg, TkAgg and WxAgg and
- PS, though only horizontal and vertical rotations are supported in
- *Agg
+ mathtext currently works with all backends.
 
- mathtext now embeds the TrueType computer modern fonts into the PS
- file, so what you see on the screen should be what you get on paper.
-
- Backends which don't support mathtext will just render the TeX
- string as a literal. Stay tuned.
-
-
 KNOWN ISSUES:
 
 - Certainly there are some...
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年02月21日 19:13:17
Revision: 4985
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4985&view=rev
Author: mdboom
Date: 2008年02月21日 11:13:14 -0800 (2008年2月21日)
Log Message:
-----------
Remove case-sensitivity for backend selection. (Not a user-visible problem)
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mathtext.py
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2008年02月20日 14:11:59 UTC (rev 4984)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2008年02月21日 19:13:14 UTC (rev 4985)
@@ -2656,12 +2656,12 @@
 _parser = None
 
 _backend_mapping = {
- 'Bitmap': MathtextBackendBitmap,
- 'Agg' : MathtextBackendAgg,
- 'PS' : MathtextBackendPs,
- 'Pdf' : MathtextBackendPdf,
- 'SVG' : MathtextBackendSvg,
- 'Cairo' : MathtextBackendCairo
+ 'bitmap': MathtextBackendBitmap,
+ 'agg' : MathtextBackendAgg,
+ 'ps' : MathtextBackendPs,
+ 'pdf' : MathtextBackendPdf,
+ 'svg' : MathtextBackendSvg,
+ 'cairo' : MathtextBackendCairo
 }
 
 _font_type_mapping = {
@@ -2672,7 +2672,7 @@
 }
 
 def __init__(self, output):
- self._output = output
+ self._output = output.lower()
 self._cache = maxdict(50)
 
 def parse(self, s, dpi = 72, prop = None):
@@ -2689,7 +2689,7 @@
 else:
 backend = self._backend_mapping[self._output]()
 fontset = rcParams['mathtext.fontset']
- fontset_class = self._font_type_mapping.get(fontset)
+ fontset_class = self._font_type_mapping.get(fontset.lower())
 if fontset_class is not None:
 font_output = fontset_class(prop, backend)
 else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
1 2 > >> (Page 1 of 2)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /