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

Skip to content

Commit f76a004

Browse files
committed
Merged revisions 7794 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint ........ r7794 | jouni | 2009-09-20 15:30:22 +0300 (Su, 20 Syy 2009) | 1 line Prevent exception in case of missing height and depth information in a TeX font ........ svn path=/trunk/matplotlib/; revision=7795
1 parent 7847c50 commit f76a004

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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
4+
15
2009-09-15 Implement draw_text and draw_tex method of backend_base using
26
the textpath module. Implement draw_tex method of the svg
37
backend. - JJL

lib/matplotlib/dviread.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ def _output(self):
8888
e = 0 # zero depth
8989
else: # glyph
9090
x,y,font,g,w = elt
91-
h = _mul2012(font._scale, font._tfm.height[g])
92-
e = _mul2012(font._scale, font._tfm.depth[g])
91+
h,e = font._height_depth_of(g)
9392
minx = min(minx, x)
9493
miny = min(miny, y - h)
9594
maxx = max(maxx, x + w)
@@ -443,6 +442,24 @@ def _width_of(self, char):
443442
'debug')
444443
return 0
445444

445+
def _height_depth_of(self, char):
446+
"""
447+
Height and depth of char in dvi units. For internal use by dviread.py.
448+
"""
449+
450+
result = []
451+
for metric,name in ((self._tfm.height, "height"),
452+
(self._tfm.depth, "depth")):
453+
value = metric.get(char, None)
454+
if value is None:
455+
matplotlib.verbose.report(
456+
'No %s for char %d in font %s' % (name, char, self.texname),
457+
'debug')
458+
result.append(0)
459+
else:
460+
result.append(_mul2012(value, self._scale))
461+
return result
462+
446463
class Vf(Dvi):
447464
"""
448465
A virtual font (\*.vf file) containing subroutines for dvi files.

0 commit comments

Comments
 (0)