Font

Font class

Represents font object.

The Font type exposes the following members:

Properties

NameDescription
font_nameGets font name of the Font object.
decoded_font_nameSometimes PDF fonts(usually Chinese/Japanese/Korean fonts) could have specificical font name.
This name is value of PDF font property “BaseFont” and sometimes this property
could be represented in hexademical form. If read this name directly it could be represented
in non-readable form. To get readable form it’s necessary to decode font’s name by
rules specifical for this font.
This property returns decoded font name, so use it for cases when you meet
with a non-readable font_name.
If property font_name has readable form this property will be the same as
font_name, so you can use this property for any cases when you need to
get font name in a readable form.
base_fontGets BaseFont value of PDF font object. Also known as PostScript name of the font.
is_embeddedGets or sets a value that indicates whether the font is embedded.
Font based on IFont will automatically be subset and embedded
is_subsetGets or sets a value that indicates whether the font is a subset.
Font based on IFont will automatically be subset and embedded
is_accessibleGets indicating whether the font is present (installed) in the system.
font_optionsUseful properties to tune Font behaviour

Methods

NameDescription
get_last_font_embedding_error()An objective of this method - to return description of error if an attempt
to embed font was failed. If there are no error cases it returns empty string.
save(stream)Saves the font into the stream.
Note that the font is saved to intermediate TTF format intended to be used in a converted copy of the original document only.
The font file is not intended to be used outside the original document context.
measure_string(str, font_size)Measures the string.

See Also