Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8765290

Browse files
committed
Merged revisions 7796 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint ........ r7796 | jouni | 2009-09-20 16:19:25 +0300 (Su, 20 Syy 2009) | 1 line Fix off-by-one error in dviread.Tfm ........ svn path=/trunk/matplotlib/; revision=7797
1 parent f76a004 commit 8765290

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

CHANGELOG

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
2009-09-20 Prevent exception in case of missing height and depth information
2-
in a TeX font - this doesn't make the typesetting right, but prevents
3-
the crash - JKS
1+
2009-09-20 Fix off-by-one error in dviread.Tfm, and additionally protect
2+
against exceptions in case a dvi font is missing some metrics - JKS
43

54
2009-09-15 Implement draw_text and draw_tex method of backend_base using
65
the textpath module. Implement draw_tex method of the svg

lib/matplotlib/dviread.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def __init__(self, scale, tfm, texname, vf):
415415
scale, tfm, texname, vf
416416
self.size = scale * (72.0 / (72.27 * 2**16))
417417
try:
418-
nchars = max(tfm.width.iterkeys())
418+
nchars = max(tfm.width.iterkeys()) + 1
419419
except ValueError:
420420
nchars = 0
421421
self.widths = [ (1000*tfm.width.get(char, 0)) >> 20
@@ -619,11 +619,10 @@ def __init__(self, filename):
619619
widths, heights, depths = \
620620
[ struct.unpack('!%dI' % (len(x)/4), x)
621621
for x in (widths, heights, depths) ]
622-
for i in range(ec-bc):
623-
self.width[bc+i] = _fix2comp(widths[ord(char_info[4*i])])
624-
self.height[bc+i] = _fix2comp(heights[ord(char_info[4*i+1]) >> 4])
625-
self.depth[bc+i] = _fix2comp(depths[ord(char_info[4*i+1]) & 0xf])
626-
622+
for idx, char in enumerate(range(bc, ec+1)):
623+
self.width[char] = _fix2comp(widths[ord(char_info[4*idx])])
624+
self.height[char] = _fix2comp(heights[ord(char_info[4*idx+1]) >> 4])
625+
self.depth[char] = _fix2comp(depths[ord(char_info[4*idx+1]) & 0xf])
627626

628627
class PsfontsMap(object):
629628
"""

0 commit comments

Comments
 (0)