8000 Cleanup afm module docstring. · matplotlib/matplotlib@a89c9df · GitHub
[go: up one dir, main page]

Skip to content

Commit a89c9df

Browse files
committed
Cleanup afm module docstring.
1 parent 520b5f6 commit a89c9df

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

lib/matplotlib/afm.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
11
"""
22
This is a python interface to Adobe Font Metrics Files. Although a
33
number of other python implementations exist, and may be more complete
4-
than this, it was decided not to go with them because they were
5-
either:
4+
than this, it was decided not to go with them because they were either:
65
7-
1) copyrighted or used a non-BSD compatible license
8-
9-
2) had too many dependencies and a free standing lib was needed
10-
11-
3) Did more than needed and it was easier to write afresh rather than
12-
figure out how to get just what was needed.
6+
1) copyrighted or used a non-BSD compatible license
7+
2) had too many dependencies and a free standing lib was needed
8+
3) did more than needed and it was easier to write afresh rather than
9+
figure out how to get just what was needed.
1310
1411
It is pretty easy to use, and requires only built-in python libs:
1512
16-
>>> import matplotlib as mpl
17-
>>> import os.path
18-
>>> afm_fname = os.path.join(mpl.get_data_path(),
19-
... 'fonts', 'afm', 'ptmr8a.afm')
20-
>>>
21-
>>> from matplotlib.afm import AFM
22-
>>> with open(afm_fname, 'rb') as fh:
23-
... afm = AFM(fh)
24-
>>> afm.string_width_height('What the heck?')
25-
(6220.0, 694)
26-
>>> afm.get_fontname()
27-
'Times-Roman'
28-
>>> afm.get_kern_dist('A', 'f')
29-
0
30-
>>> afm.get_kern_dist('A', 'y')
31-
-92.0
32-
>>> afm.get_bbox_char('!')
33-
[130, -9, 238, 676]
13+
>>> import matplotlib as mpl
14+
>>> from pathlib import Path
15+
>>> afm_path = Path(mpl.get_data_path(), 'fonts', 'afm', 'ptmr8a.afm')
16+
>>>
17+
>>> from matplotlib.afm import AFM
18+
>>> with afm_path.open('rb') as fh:
19+
... afm = AFM(fh)
20+
>>> afm.string_width_height('What the heck?')
21+
(6220.0, 694)
22+
>>> afm.get_fontname()
23+
'Times-Roman'
24+
>>> afm.get_kern_dist('A', 'f')
25+
0
26+
>>> afm.get_kern_dist('A', 'y')
27+
-92.0
28+
>>> afm.get_bbox_char('!')
29+
[130, -9, 238, 676]
3430
3531
As in the Adobe Font Metrics File Format Specification, all dimensions
3632
are given in units of 1/1000 of the scale factor (point size) of the font

0 commit comments

Comments
 (0)
0