TtfFont

Overview

TtfFont is a class in Aspose.Font FOSS for Python. Inherits from: Font.

TtfFont.save(path) writes the current font instance to the supplied filesystem path in its native format.

This class provides 23 methods for working with TtfFont objects in Python programs. Available methods include: __init__, available_naming_strategies, convert, encoding, font_family, font_name, font_style, font_type, get_axis, get_blob, get_kern_pairs, get_named_instance, and 11 additional methods. All public members are accessible to any Python application after installing the Aspose.Font FOSS for Python package. Properties: axes, cff_font, encoding, font_family, font_name, font_style, and 12 more.

Properties

NameTypeAccessDescription
font_typeFontTypeReadGets the font type.
font_namestrReadGets the font name.
font_familystrReadGets the font family.
font_stylestrReadGets the font style.
num_glyphsintReadGets the num glyphs.
metricsFontMetricsReadGets the metrics.
encodingFontEncodingReadGets the encoding.
glyph_accessorGlyphAccessorReadGets the glyph accessor.
ttf_tablesTtfTableSetReadGets the ttf tables.
cff_font``ReadGets the cff font.
fvar"FvarTable | None"ReadLazily parse and return the FVAR table, or None if not a variable font.
hvar"HvarTable | None"ReadGets the hvar.
is_variableboolReadGets the is variable.
axes"list[AxisRecord]"ReadGets the axes.
named_instances"list[NamedInstance]"ReadGets the named instances.
variable_axeslist[VariableAxis]ReadGets the variable axes.
variable_instanceslist[VariableInstance]ReadGets the variable instances.
smart_instancer``ReadGets the smart instancer.

Methods

SignatureDescription
__init__(sfnt_data: bytes, tables: TtfTableSet, sfnt_version: int)Calls init on this TtfFont instance.
get_blob(tag: str)bytes | NoneReturns the raw bytes of the table identified by tag, or None if missing
get_table_bytes(tag: str)bytesReturns the bytes of the specified TrueType table
set_table_bytes(tag: str, data: bytes)Sets the table bytes value.
get_axis(tag: str)VariableAxis | NoneReturns a VariableAxis object for the given axis tag, or None if not present
get_named_instance(name: str, preferred_languages: str | tuple[str, ...])VariableInstance | NoneReturns a VariableInstance matching the name and language preferences, or None
variable_presentation(preferred_languages: str | tuple[str, ...], include_suggested_values: bool)dict[str, object]Returns a dict describing variable font axes and suggested values for given languages
available_naming_strategies()tuple[str, ...]Returns a tuple of supported naming strategy identifiers
instantiate(coordinates: dict[str, float], naming_strategy: str, family_suffix: str | None, legacy_family_name: str | None, typographic_family_name: str | None, legacy_style_name: str | None, typographic_style_name: str | None, stat_policy: str)"TtfFont"Creates a new static TtfFont using coordinates and naming options
preview_naming_policy(coordinates: dict[str, float], naming_strategy: str, family_suffix: str | None, legacy_family_name: str | None, typographic_family_name: str | None, legacy_style_name: str | None, typographic_style_name: str | None, stat_policy: str)Computes naming data for a preview without creating a new font
get_kern_pairs()list[KernPair]Returns the kern pairs.
to_bytes(font_type: FontType | None)bytesSerializes the font to bytes, optionally as a specific FontType
font_type()FontTypeReturns the FontType enumeration of the current font
font_name()strProperty holds the font’s full name string
font_family()strProperty holds the family name
font_style()strProperty holds the style name
num_glyphs()intProperty holds the glyph count
metrics()FontMetricsReturns a FontMetrics object with size and spacing data
encoding()FontEncodingReturns a FontEncoding object describing character mapping
glyph_accessor()GlyphAccessorReturns a GlyphAccessor for low-level glyph operations
save(path: str)` writes the current state of a TrueType font to the filesystem at the specified location
save_to_format(font_type: FontType, path: str)Calls save_to_format on this TtfFont instance.
convert(target: FontType)FontReturns a Font object converted to the target FontType

See Also