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

Skip to content

Commit e87374e

Browse files
committed
Merge pull request #864 from goir/patch-1
AFM - Kerning information is not used
2 parents decc317 + 02dee87 commit e87374e

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

lib/matplotlib/afm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ def string_width_height(self, s):
348348
# find the min y
349349
thismin = b
350350
if thismin<miny: miny = thismin
351+
namelast = name
351352

352353
return totalw, maxy-miny
353354

@@ -385,6 +386,7 @@ def get_str_bbox_and_descent(self, s):
385386
# find the min y
386387
thismin = b
387388
if thismin<miny: miny = thismin
389+
namelast = name
388390

389391
return left, miny, totalw, maxy-miny, -miny
390392

lib/matplotlib/tests/test_text.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,13 @@ def test_antialiasing():
9595
# test cleanup will do it for us. In fact, if we do it here, it
9696
# will turn antialiasing back off before the images are actually
9797
# rendered.
98+
99+
100+
def test_afm_kerning():
101+
from matplotlib.afm import AFM
102+
from matplotlib.font_manager import findfont
103+
104+
fn = findfont("Helvetica", fontext="afm")
105+
with open(fn, 'rb') as fh:
106+
afm = AFM(fh)
107+
assert afm.string_width_height('VAVAVAVAVAVA') == (7174.0, 718)

0 commit comments

Comments
 (0)