Mathtext widebar support (with patch)

Greetings,

I've been checking out the code in lib/matplotlib/mathtext.py with the
hope of adding support for a "widebar". I have something that works,
although unlike \widetilde and \widehat, I can only find one glyph and
it's in cmr10. I've attached a patch that adds \widebar support using
svn rev 7943 if anyone is interested!

Cheers!

Sean Arms
University of Oklahoma
School of Meteorology
PhD Candidate

Index: lib/matplotlib/mathtext.py

mathtext_widebar.patch (796 Bytes)

···

===================================================================
--- lib/matplotlib/mathtext.py (revision 7943)
+++ lib/matplotlib/mathtext.py (working copy)
@@ -769,6 +769,7 @@
                        ('ex', '\x64')],
        r'\widetilde': [('rm', '\x7e'), ('ex', '\x65'), ('ex', '\x66'),
                        ('ex', '\x67')],
+ r'\widebar' : [('rm', '\xB9')],
        r'<' : [('cal', 'h'), ('ex', 'D')],
        r'>' : [('cal', 'i'), ('ex', 'E')]
        }
@@ -2481,7 +2482,7 @@
        r'overleftarrow' : r'\leftarrow'
        }

- _wide_accents = set(r"widehat widetilde".split())
+ _wide_accents = set(r"widehat widetilde widebar".split())

    def accent(self, s, loc, toks):
        assert(len(toks)==1)

This is a good suggestion.

I've committed your patch (with a slight modification so it works with the STIX fonts also) in SVN r7944 and r7645.

Thanks, and more patches always welcome!

Mike

Sean Arms wrote:

···

Greetings,

I've been checking out the code in lib/matplotlib/mathtext.py with the
hope of adding support for a "widebar". I have something that works,
although unlike \widetilde and \widehat, I can only find one glyph and
it's in cmr10. I've attached a patch that adds \widebar support using
svn rev 7943 if anyone is interested!

Cheers!

Sean Arms
University of Oklahoma
School of Meteorology
PhD Candidate

Index: lib/matplotlib/mathtext.py

--- lib/matplotlib/mathtext.py (revision 7943)
+++ lib/matplotlib/mathtext.py (working copy)
@@ -769,6 +769,7 @@
                        ('ex', '\x64')],
        r'\widetilde': [('rm', '\x7e'), ('ex', '\x65'), ('ex', '\x66'),
                        ('ex', '\x67')],
+ r'\widebar' : [('rm', '\xB9')],
        r'<' : [('cal', 'h'), ('ex', 'D')],
        r'>' : [('cal', 'i'), ('ex', 'E')]
        }
@@ -2481,7 +2482,7 @@
        r'overleftarrow' : r'\leftarrow'
        }

- _wide_accents = set(r"widehat widetilde".split())
+ _wide_accents = set(r"widehat widetilde widebar".split())

    def accent(self, s, loc, toks):
        assert(len(toks)==1)
  ------------------------------------------------------------------------

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
------------------------------------------------------------------------

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA