Revision: 7796
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7796&view=rev
Author:   jouni
Date:     2009-09-20 13:19:25 +0000 (Sun, 20 Sep 2009)

Log Message:
-----------
Fix off-by-one error in dviread.Tfm

Modified Paths:
--------------
    branches/v0_99_maint/CHANGELOG
    branches/v0_99_maint/lib/matplotlib/dviread.py

Modified: branches/v0_99_maint/CHANGELOG
===================================================================
--- branches/v0_99_maint/CHANGELOG      2009-09-20 13:07:15 UTC (rev 7795)
+++ branches/v0_99_maint/CHANGELOG      2009-09-20 13:19:25 UTC (rev 7796)
@@ -1,6 +1,5 @@
-2009-09-20 Prevent exception in case of missing height and depth information
-           in a TeX font - this doesn't make the typesetting right, but 
prevents
-           the crash - JKS
+2009-09-20 Fix off-by-one error in dviread.Tfm, and additionally protect
+           against exceptions in case a dvi font is missing some metrics - JKS
 
 2009-09-15 Don't fail on AFM files containing floating-point bounding boxes - 
JKS
 

Modified: branches/v0_99_maint/lib/matplotlib/dviread.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/dviread.py      2009-09-20 13:07:15 UTC 
(rev 7795)
+++ branches/v0_99_maint/lib/matplotlib/dviread.py      2009-09-20 13:19:25 UTC 
(rev 7796)
@@ -415,7 +415,7 @@
             scale, tfm, texname, vf
         self.size = scale * (72.0 / (72.27 * 2**16))
         try:
-            nchars = max(tfm.width.iterkeys())
+            nchars = max(tfm.width.iterkeys()) + 1
         except ValueError:
             nchars = 0
         self.widths = [ (1000*tfm.width.get(char, 0)) >> 20
@@ -619,12 +619,11 @@
         widths, heights, depths = \
             [ struct.unpack('!%dI' % (len(x)/4), x)
               for x in (widths, heights, depths) ]
-        for i in range(ec-bc):
-            self.width[bc+i] = _fix2comp(widths[ord(char_info[4*i])])
-            self.height[bc+i] = _fix2comp(heights[ord(char_info[4*i+1]) >> 4])
-            self.depth[bc+i] = _fix2comp(depths[ord(char_info[4*i+1]) & 0xf])
+        for idx, char in enumerate(range(bc, ec+1)):
+            self.width[char] = _fix2comp(widths[ord(char_info[4*idx])])
+            self.height[char] = _fix2comp(heights[ord(char_info[4*idx+1]) >> 
4])
+            self.depth[char] = _fix2comp(depths[ord(char_info[4*idx+1]) & 0xf])
 
-
 class PsfontsMap(object):
     """
     A psfonts.map formatted file, mapping TeX fonts to PS fonts.


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

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to