From: <md...@us...> - 2008-07-09 13:39:50
|
Revision: 5724 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5724&view=rev Author: mdboom Date: 2008-07-09 06:39:36 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Merged revisions 5721-5723 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint ........ r5723 | mdboom | 2008-07-09 09:33:13 -0400 (Wed, 09 Jul 2008) | 2 lines Improve mathtext radical rendering ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/mathtext.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5720 + /branches/v0_91_maint:1-5723 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-07-09 13:33:13 UTC (rev 5723) +++ trunk/matplotlib/CHANGELOG 2008-07-09 13:39:36 UTC (rev 5724) @@ -1,3 +1,5 @@ +2008-07-09 Improve mathtext radical rendering - MGD + 2008-07-08 Improve mathtext superscript placement - MGD 2008-07-07 Fix custom scales in pcolormesh (thanks Matthew Turk) - MGD Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2008-07-09 13:33:13 UTC (rev 5723) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008-07-09 13:39:36 UTC (rev 5724) @@ -322,7 +322,13 @@ self.image, ox, oy - info.metrics.ymax, info.glyph) def render_rect_filled(self, x1, y1, x2, y2): - self.image.draw_rect_filled(x1, y1, x2, max(y2 - 1, y1)) + height = max(int(y2 - y1) - 1, 0) + if height == 0: + center = (y2 + y1) / 2.0 + y = int(center - (height + 1) / 2.0) + else: + y = int(y1) + self.image.draw_rect_filled(int(x1), y, ceil(x2), y + height) def get_results(self, box): return (self.ox, @@ -481,8 +487,8 @@ to be destroyed.""" self.used_characters = None - def get_kern(self, font1, sym1, fontsize1, - font2, sym2, fontsize2, dpi): + def get_kern(self, font1, fontclass1, sym1, fontsize1, + font2, fontclass2, sym2, fontsize2, dpi): """ Get the kerning distance for font between sym1 and sym2. @@ -670,7 +676,8 @@ info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi) font = info1.font return font.get_kerning(info1.num, info2.num, KERNING_DEFAULT) / 64.0 - return 0.0 + return Fonts.get_kern(self, font1, fontclass1, sym1, fontsize1, + font2, fontclass2, sym2, fontsize2, dpi) class BakomaFonts(TruetypeFonts): """ @@ -1123,7 +1130,8 @@ font = info1.font return (font.get_kern_dist(info1.glyph, info2.glyph) * 0.001 * fontsize1) - return 0.0 + return Fonts.get_kern(self, font1, fontclass1, sym1, fontsize1, + font2, fontclass2, sym2, fontsize2, dpi) def get_xheight(self, font, fontsize, dpi): cached_font = self._get_font(font) @@ -1433,6 +1441,19 @@ new_children.append(kern) self.children = new_children + # This is a failed experiment to fake cross-font kerning. +# def get_kerning(self, next): +# if len(self.children) >= 2 and isinstance(self.children[-2], Char): +# if isinstance(next, Char): +# print "CASE A" +# return self.children[-2].get_kerning(next) +# elif isinstance(next, Hlist) and len(next.children) and isinstance(next.children[0], Char): +# print "CASE B" +# result = self.children[-2].get_kerning(next.children[0]) +# print result +# return result +# return 0.0 + def hpack(self, w=0., m='additional'): """The main duty of hpack is to compute the dimensions of the resulting boxes, and to adjust the glue if one of those dimensions is @@ -2593,13 +2614,6 @@ thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) - if root is None: - root = Box(0., 0., 0.) - else: - root = Hlist([Char(x, state) for x in root]) - root.shrink() - root.shrink() - # Determine the height of the body, and add a little extra to # the height so it doesn't seem cramped height = body.height - body.shift_amount + thickness * 5.0 @@ -2616,10 +2630,18 @@ Fill(), padded_body]) # Stretch the glue between the hrule and the body - rightside.vpack(height + 1.0, depth, 'exactly') + rightside.vpack(height + (state.fontsize * state.dpi) / (100.0 * 12.0), + depth, 'exactly') # Add the root and shift it upward so it is above the tick. # The value of 0.6 is a hard-coded hack ;) + if root is None: + root = Box(check.width * 0.5, 0., 0.) + else: + root = Hlist([Char(x, state) for x in root]) + root.shrink() + root.shrink() + root_vlist = Vlist([Hlist([root])]) root_vlist.shift_amount = -height * 0.6 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |