Path
(
mpl
.
get_data_path
(),
'fonts'
,
'afm'
,
'ptmr8a.afm'
)
from
matplotlib._afm
import
AFM
with
afm_path
.
open
(
'rb'
)
as
fh
:
afm
=
AFM
(
fh
)
afm
.
get_fontname
()
'Times-Roman'
As in the Adobe Font Metrics File Format Specification, all dimensions
are given in units of 1/1000 of the scale factor (point size) of the font
being used.
-
class matplotlib._afm.AFM(fh)
Bases: object
Parse the AFM file in file object fh.
-
property family_name
The font family name, e.g., 'Times'.
-
get_angle()
Return the fontangle as float.
-
get_ascender()
Return the ascent as float.
-
get_capheight()
Return the cap height as float.
-
get_char_index(c)
Return the glyph index corresponding to a character code point.
Note, for AFM fonts, we treat the glyph index the same as the codepoint.
-
get_descender()
Return the descent as float.
-
get_familyname()
Return the font family name, e.g., 'Times'.
-
get_fontname()
Return the font name, e.g., 'Times-Roman'.
-
get_fullname()
Return the font full name, e.g., 'Times-Roman'.
-
get_glyph_name(glyph_ind)
Get the name of the glyph, i.e., ord(';') is 'semicolon'.
-
get_kern_dist_from_name(name1, name2)
Return the kerning pair distance (possibly 0) for chars name1 and name2.
-
get_str_bbox_and_descent(s)
Return the string bounding box and the maximal descent.
-
get_underline_thickness()
Return the underline thickness as float.
-
get_weight()
Return the font weight, e.g., 'Bold' or 'Roman'.
-
get_width_char(c)
Get the width of the character code from the character metric WX field.
-
get_width_from_char_name(name)
Get the width of the character from a type1 character name.
-
get_xheight()
Return the xheight as float.
-
property postscript_name
-
class matplotlib._afm.CharMetrics(width, name, bbox)
Bases: NamedTuple
Represents the character metrics of a single character.
Notes
The fields do currently only describe a subset of character metrics
information defined in the AFM standard.
Create new instance of CharMetrics(width, name, bbox)
-
bbox
The bbox of the character (B) as a tuple (llx, lly, urx, ury).
-
name
The character name (N).
-
width
The character width (WX).
-
class matplotlib._afm.CompositePart(name, dx, dy)
Bases: NamedTuple
Represents the information on a composite element of a composite char.
Create new instance of CompositePart(name, dx, dy)
-
dx
x-displacement of the part from the origin.
-
dy
y-displacement of the part from the origin.
-
name
Name of the part, e.g. 'acute'.