Revision: 3612
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3612&view=rev
Author:   mdboom
Date:     2007-07-25 08:34:52 -0700 (Wed, 25 Jul 2007)

Log Message:
-----------
Fix for get_xheight/get_underline_thickness.  Update examples to use
new math syntax.

Modified Paths:
--------------
    branches/mathtext_mgd/examples/mathtext_demo.py
    branches/mathtext_mgd/lib/matplotlib/mathtext.py

Modified: branches/mathtext_mgd/examples/mathtext_demo.py
===================================================================
--- branches/mathtext_mgd/examples/mathtext_demo.py     2007-07-25 14:43:13 UTC 
(rev 3611)
+++ branches/mathtext_mgd/examples/mathtext_demo.py     2007-07-25 15:34:52 UTC 
(rev 3612)
@@ -17,8 +17,8 @@
 grid(True)
 xlabel(r'$\Delta_i^j$', fontsize=20)
 ylabel(r'$\Delta_{i+1}^j$', fontsize=20)
-tex = r'$\cal{R}\prod_{i=\alpha_{i+1}}^\infty a_i\rm{sin}(2 \pi f x_i)$'
-text(1, 1.6, tex, fontsize=20)
+tex = r'$\mathcal{R}\prod_{i=\alpha_{i+1}}^\infty a_i\sin(2 \pi f x_i)$'
+text(1, 1.6, tex, fontsize=20, va='bottom')
 
 #title(r'$\Delta_i^j \hspace{0.4} \rm{versus} \hspace{0.4} \Delta_{i+1}^j$', 
fontsize=20)
 savefig('mathtext_demo')

Modified: branches/mathtext_mgd/lib/matplotlib/mathtext.py
===================================================================
--- branches/mathtext_mgd/lib/matplotlib/mathtext.py    2007-07-25 14:43:13 UTC 
(rev 3611)
+++ branches/mathtext_mgd/lib/matplotlib/mathtext.py    2007-07-25 15:34:52 UTC 
(rev 3612)
@@ -699,7 +699,6 @@
         basename, font, metrics, symbol_name, num, glyph, offset = \
             self._get_info(font, sym, fontsize, dpi)
 
-        font.draw_rect(0, 0, self.width - 1, self.height - 1)
         font.draw_glyph_to_bitmap(
             int(ox),  int(oy - metrics.ymax), glyph)
 
@@ -711,16 +710,16 @@
     def get_used_characters(self):
         return self.used_characters
 
-    def get_xheight(self, font, fontsize):
+    def get_xheight(self, font, fontsize, dpi):
         basename, cached_font = self._get_font(font)
-        cached_font.font.set_size(fontsize)
+        cached_font.font.set_size(fontsize, dpi)
         pclt = cached_font.font.get_sfnt_table('pclt')
         xHeight = pclt['xHeight'] / 64.0
         return xHeight
 
-    def get_underline_thickness(self, font, fontsize):
+    def get_underline_thickness(self, font, fontsize, dpi):
         basename, cached_font = self._get_font(font)
-        cached_font.font.set_size(fontsize)
+        cached_font.font.set_size(fontsize, dpi)
         return max(1.0, cached_font.font.underline_thickness / 64.0)
 
     def get_kern(self, fontleft, symleft, fontsizeleft,
@@ -944,11 +943,11 @@
         ps = "%f %f %f %f rectfill" % (x1, self.height - y2, x2 - x1, y2 - y1)
         self.pswriter.write(ps)
 
-    def get_xheight(self, font, fontsize):
+    def get_xheight(self, font, fontsize, dpi):
         basename, cached_font = self._get_font(font)
         return cached_font.get_xheight() * 0.001 * fontsize
 
-    def get_underline_thickness(self, font, fontsize):
+    def get_underline_thickness(self, font, fontsize, dpi):
         basename, cached_font = self._get_font(font)
         return cached_font.get_underline_thickness() * 0.001 * fontsize
     
@@ -1367,7 +1366,7 @@
     """Convenience class to create a horizontal rule."""
     def __init__(self, state):
         thickness = state.font_output.get_underline_thickness(
-            state.font, state.fontsize)
+            state.font, state.fontsize, state.dpi)
         height = depth = thickness * 0.5
         Rule.__init__(self, None, height, depth, state)
 
@@ -1375,7 +1374,7 @@
     """Convenience class to create a vertical rule."""
     def __init__(self, state):
         thickness = state.font_output.get_underline_thickness(
-            state.font, state.fontsize)
+            state.font, state.fontsize, state.dpi)
         Rule.__init__(self, thickness, None, None, state)
         
 class Glue(Node):
@@ -1950,6 +1949,7 @@
         return [box]
 
     def symbol(self, s, loc, toks):
+        # print "symbol", toks
         c = toks[0]
         if c in self._spaced_symbols:
             return [Hlist([self._make_space(0.3),
@@ -1982,7 +1982,7 @@
         assert(len(toks)==1)
         state = self.get_state()
         thickness = state.font_output.get_underline_thickness(
-            state.font, state.fontsize)
+            state.font, state.fontsize, state.dpi)
         accent, sym = toks[0]
         accent = Accent(self._accent_map[accent], self.get_state())
         centered = HCentered([accent])
@@ -2067,11 +2067,12 @@
                 sub = next2
         else:
             raise ParseFatalException("Subscript/superscript string is too 
long.")
-
+        
         state = self.get_state()
         rule_thickness = state.font_output.get_underline_thickness(
-            state.font, state.fontsize)
-        xHeight = state.font_output.get_xheight(state.font, state.fontsize)
+            state.font, state.fontsize, state.dpi)
+        xHeight = state.font_output.get_xheight(
+            state.font, state.fontsize, state.dpi)
         
         if self.is_overunder(nucleus):
             vlist = []
@@ -2155,7 +2156,7 @@
         cden.hpack(width, 'exactly')
         state = self.get_state()
         thickness = state.font_output.get_underline_thickness(
-            state.font, state.fontsize)
+            state.font, state.fontsize, state.dpi)
         space = thickness * 3.0
         vlist = Vlist([cnum,
                        FixedGlue(thickness * 2.0),
@@ -2243,7 +2244,7 @@
             pswriter = list()
             font_output.set_canvas_size(w, h, pswriter)
         ship(2, 2, box)
-        
+
         if self.output == 'SVG':
             # The empty list at the end is for lines
             svg_elements = Bunch(svg_glyphs=font_output.svg_glyphs,


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