Revision: 3635
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3635&view=rev
Author:   mdboom
Date:     2007-07-30 11:57:09 -0700 (Mon, 30 Jul 2007)

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.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to