FontInfo class

FontInfo class

Specifies information about a font used in the document. To learn more, visit the Working with Fonts documentation article.

Remarks

You do not create instances of this class directly. Use the DocumentBase.font_infos property to access the collection of fonts defined in a document.

Properties

NameDescription
alt_nameGets or sets the alternate name for the font.
charsetGets or sets the character set for the font.
embedding_licensing_rightsGets the embedded font licensing rights.
familyGets or sets the font family this font belongs to.
is_true_typeIndicates that this font is a TrueType or OpenType font as opposed to a raster or vector font. Default is True.
nameGets the name of the font.
panoseGets or sets the PANOSE typeface classification number.
pitchThe pitch indicates if the font is fixed pitch, proportionally spaced, or relies on a default setting.

Methods

NameDescription
get_embedded_font(format, style)Gets a specific embedded font file.
get_embedded_font_as_open_type(style)Gets an embedded font file in OpenType format. Fonts in Embedded OpenType format are converted to OpenType.

Examples

Shows how to print the details of what fonts are present in a document.

doc = aw.Document(MY_DIR + 'Embedded font.docx')
all_fonts = doc.font_infos
# Print all the used and unused fonts in the document.
for i in range(all_fonts.count):
    print(f'Font index #{i}')
    print(f'\tName: {all_fonts[i].name}')
    print(f"\tIs {('' if all_fonts[i].is_true_type else 'not ')}a TrueType font")

See Also