Revision: 5573
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5573&view=rev
Author:   mdboom
Date:     2008-06-17 07:55:52 -0700 (Tue, 17 Jun 2008)

Log Message:
-----------
Fix STIX fonts on narrow Unicode platforms.

Modified Paths:
--------------
    branches/v0_91_maint/lib/matplotlib/_mathtext_data.py
    branches/v0_91_maint/lib/matplotlib/backends/backend_pdf.py
    branches/v0_91_maint/lib/matplotlib/backends/backend_ps.py
    branches/v0_91_maint/lib/matplotlib/mathtext.py

Modified: branches/v0_91_maint/lib/matplotlib/_mathtext_data.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/_mathtext_data.py       2008-06-17 
14:46:00 UTC (rev 5572)
+++ branches/v0_91_maint/lib/matplotlib/_mathtext_data.py       2008-06-17 
14:55:52 UTC (rev 5573)
@@ -39,6 +39,8 @@
     r'\}'                   : ('cmex10', 130),
     r'\leftangle'           : ('cmex10',  97),
     r'\rightangle'          : ('cmex10',  64),
+    r'\langle'              : ('cmex10',  97),
+    r'\rangle'              : ('cmex10',  64),
     r'\widehat'             : ('cmex10',  15),
     r'\widetilde'           : ('cmex10',  52),
 
@@ -1761,6 +1763,54 @@
 tex2uni = {
 'widehat': 0x0302,
 'widetilde': 0x0303,
+'langle': 0x27e8,
+'rangle': 0x27e9,
+'perp': 0x27c2,
+'neq': 0x2260,
+'Join': 0x2a1d,
+'leqslant': 0x2a7d,
+'geqslant': 0x2a7e,
+'lessapprox': 0x2a85,
+'gtrapprox': 0x2a86,
+'lesseqqgtr': 0x2a8b,
+'gtreqqless': 0x2a8c,
+'triangleeq': 0x225c,
+'eqslantless': 0x2a95,
+'eqslantgtr': 0x2a96,
+'backepsilon': 0x03f6,
+'precapprox': 0x2ab7,
+'succapprox': 0x2ab8,
+'fallingdotseq': 0x2252,
+'subseteqq': 0x2ac5,
+'supseteqq': 0x2ac6,
+'varpropto': 0x221d,
+'precnapprox': 0x2ab9,
+'succnapprox': 0x2aba,
+'subsetneqq': 0x2acb,
+'supsetneqq': 0x2acc,
+'lnapprox': 0x2ab9,
+'gnapprox': 0x2aba,
+'longleftarrow': 0x27f5,
+'longrightarrow': 0x27f6,
+'longleftrightarrow': 0x27f7,
+'Longleftarrow': 0x27f8,
+'Longrightarrow': 0x27f9,
+'Longleftrightarrow': 0x27fa,
+'longmapsto': 0x27fc,
+'leadsto': 0x21dd,
+'dashleftarrow': 0x290e,
+'dashrightarrow': 0x290f,
+'circlearrowleft': 0x21ba,
+'circlearrowright': 0x21bb,
+'leftrightsquigarrow': 0x21ad,
+'leftsquigarrow': 0x219c,
+'rightsquigarrow': 0x219d,
+'Game': 0x2141,
+'hbar': 0x0127,
+'hslash': 0x210f,
+'ldots': 0x22ef,
+'vdots': 0x22ee,
+'doteqdot': 0x2251,
 'doteq': 8784,
 'partial': 8706,
 'gg': 8811,

Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_pdf.py 2008-06-17 
14:46:00 UTC (rev 5572)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_pdf.py 2008-06-17 
14:55:52 UTC (rev 5573)
@@ -683,7 +683,7 @@
             differences = []
             two_byte_chars = Set()
             for c in characters:
-                ccode = ord(c)
+                ccode = c
                 gind = cmap.get(ccode) or 0
                 glyph_ids.append(gind)
                 glyph_name = font.get_glyph_name(gind)
@@ -799,7 +799,7 @@
             widths = []
             max_ccode = 0
             for c in characters:
-                ccode = ord(c)
+                ccode = c
                 gind = cmap.get(ccode) or 0
                 glyph = font.load_char(ccode, flags=LOAD_NO_HINTING)
                 widths.append((ccode, glyph.horiAdvance / 6))
@@ -1194,7 +1194,7 @@
         realpath, stat_key = get_realpath_and_stat(fname)
         used_characters = self.used_characters.setdefault(
             stat_key, (realpath, Set()))
-        used_characters[1].update(s)
+        used_characters[1].update([ord(x) for x in s])
 
     def merge_used_characters(self, other):
         for stat_key, (realpath, set) in other.items():

Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_ps.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_ps.py  2008-06-17 
14:46:00 UTC (rev 5572)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_ps.py  2008-06-17 
14:55:52 UTC (rev 5573)
@@ -151,14 +151,14 @@
         self.mathtext_parser = MathTextParser("PS")
 
         self._clip_paths = dict()
-        
+
     def track_characters(self, font, s):
         """Keeps track of which characters are required from
         each font."""
         realpath, stat_key = get_realpath_and_stat(font.fname)
         used_characters = self.used_characters.setdefault(
             stat_key, (realpath, Set()))
-        used_characters[1].update(s)
+        used_characters[1].update([ord(x) for x in s])
 
     def merge_used_characters(self, other):
         for stat_key, (realpath, set) in other.items():
@@ -1231,7 +1231,7 @@
                     cmap = font.get_charmap()
                     glyph_ids = []
                     for c in chars:
-                        gind = cmap.get(ord(c)) or 0
+                        gind = cmap.get(c) or 0
                         glyph_ids.append(gind)
                     # The ttf to ps (subsetting) support doesn't work for
                     # OpenType fonts that are Postscript inside (like the

Modified: branches/v0_91_maint/lib/matplotlib/mathtext.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/mathtext.py     2008-06-17 14:46:00 UTC 
(rev 5572)
+++ branches/v0_91_maint/lib/matplotlib/mathtext.py     2008-06-17 14:55:52 UTC 
(rev 5573)
@@ -522,7 +522,7 @@
         realpath, stat_key = get_realpath_and_stat(info.font.fname)
         used_characters = self.used_characters.setdefault(
             stat_key, (realpath, Set()))
-        used_characters[1].update(unichr(info.num))
+        used_characters[1].add(info.num)
         self.mathtext_backend.render_glyph(ox, oy, info)
 
     def render_rect_filled(self, x1, y1, x2, y2):
@@ -655,8 +655,9 @@
         return xHeight
 
     def get_underline_thickness(self, font, fontsize, dpi):
-        cached_font = self._get_font(font)
-        return cached_font.font.underline_thickness / 64.0 / fontsize * (10.0 
* dpi / 100.0)
+        # This function used to grab underline thickness from the font,
+        # but that information is just too un-reliable, so it is now hardcoded.
+        return ((0.75 / 12.0) * fontsize * dpi) / 72.0
 
     def get_kern(self, font1, fontclass1, sym1, fontsize1,
                  font2, fontclass2, sym2, fontsize2, dpi):
@@ -840,10 +841,11 @@
             new_fontname = fontname
 
             if fontname == 'it':
-                unistring = unichr(uniindex)
-                if (not unicodedata.category(unistring)[0] == "L"
-                    or unicodedata.name(unistring).startswith("GREEK 
CAPITAL")):
-                    new_fontname = 'rm'
+                if uniindex < 0x10000:
+                    unistring = unichr(uniindex)
+                    if (not unicodedata.category(unistring)[0] == "L"
+                        or unicodedata.name(unistring).startswith("GREEK 
CAPITAL")):
+                        new_fontname = 'rm'
 
             slanted = (new_fontname == 'it') or sym in self._slanted_symbols
             found_symbol = False
@@ -868,6 +870,8 @@
                 return self.cm_fallback._get_glyph(
                     fontname, 'it', sym, fontsize)
             else:
+                if fontname == 'it' and isinstance(self, StixFonts):
+                    return self._get_glyph('rm', font_class, sym, fontsize)
                 warn("Substituting with a dummy symbol.", MathTextWarning)
                 fontname = 'rm'
                 new_fontname = fontname
@@ -2031,7 +2035,8 @@
 
         bslash       = Literal('\\')
 
-        accent       = oneOf(self._accent_map.keys() + 
list(self._wide_accents))
+        accent       = oneOf(self._accent_map.keys() +
+                             list(self._wide_accents))
 
         function     = oneOf(list(self._function_names))
 
@@ -2058,10 +2063,10 @@
 
         unicode_range = u"\U00000080-\U0001ffff"
         symbol       =(Regex(UR"([a-zA-Z0-9 
+\-*/<>=:,.;!'@()\[\]|%s])|(\\[%%${}\[\]_|])" % unicode_range)
-                     | Combine(
+                     | (Combine(
                          bslash
                        + oneOf(tex2uni.keys())
-                       )
+                       ) + FollowedBy(Regex("[^A-Za-z]")))
                      ).setParseAction(self.symbol).leaveWhitespace()
 
         c_over_c     =(Suppress(bslash)
@@ -2498,14 +2503,14 @@
             if super is not None:
                 hlist = HCentered([super])
                 hlist.hpack(width, 'exactly')
-                vlist.extend([hlist, Kern(rule_thickness * 2.0)])
+                vlist.extend([hlist, Kern(rule_thickness * 3.0)])
             hlist = HCentered([nucleus])
             hlist.hpack(width, 'exactly')
             vlist.append(hlist)
             if sub is not None:
                 hlist = HCentered([sub])
                 hlist.hpack(width, 'exactly')
-                vlist.extend([Kern(rule_thickness * 2.0), hlist])
+                vlist.extend([Kern(rule_thickness * 3.0), hlist])
                 shift = hlist.height + hlist.depth + rule_thickness * 2.0
             vlist = Vlist(vlist)
             vlist.shift_amount = shift + nucleus.depth * 0.5


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to