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
| Name | Type | Access | Description |
|---|---|---|---|
font_type | FontType | Read | Gets the font type. |
font_name | str | Read | Gets the font name. |
font_family | str | Read | Gets the font family. |
font_style | str | Read | Gets the font style. |
num_glyphs | int | Read | Gets the num glyphs. |
metrics | FontMetrics | Read | Gets the metrics. |
encoding | FontEncoding | Read | Gets the encoding. |
glyph_accessor | GlyphAccessor | Read | Gets the glyph accessor. |
ttf_tables | TtfTableSet | Read | Gets the ttf tables. |
cff_font | `` | Read | Gets the cff font. |
fvar | "FvarTable | None" | Read | Lazily parse and return the FVAR table, or None if not a variable font. |
hvar | "HvarTable | None" | Read | Gets the hvar. |
is_variable | bool | Read | Gets the is variable. |
axes | "list[AxisRecord]" | Read | Gets the axes. |
named_instances | "list[NamedInstance]" | Read | Gets the named instances. |
variable_axes | list[VariableAxis] | Read | Gets the variable axes. |
variable_instances | list[VariableInstance] | Read | Gets the variable instances. |
smart_instancer | `` | Read | Gets the smart instancer. |
Methods
| Signature | Description |
|---|---|
__init__(sfnt_data: bytes, tables: TtfTableSet, sfnt_version: int) | Calls init on this TtfFont instance. |
get_blob(tag: str) → bytes | None | Returns the raw bytes of the table identified by tag, or None if missing |
get_table_bytes(tag: str) → bytes | Returns the bytes of the specified TrueType table |
set_table_bytes(tag: str, data: bytes) | Sets the table bytes value. |
get_axis(tag: str) → VariableAxis | None | Returns a VariableAxis object for the given axis tag, or None if not present |
get_named_instance(name: str, preferred_languages: str | tuple[str, ...]) → VariableInstance | None | Returns 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) → bytes | Serializes the font to bytes, optionally as a specific FontType |
font_type() → FontType | Returns the FontType enumeration of the current font |
font_name() → str | Property holds the font’s full name string |
font_family() → str | Property holds the family name |
font_style() → str | Property holds the style name |
num_glyphs() → int | Property holds the glyph count |
metrics() → FontMetrics | Returns a FontMetrics object with size and spacing data |
encoding() → FontEncoding | Returns a FontEncoding object describing character mapping |
glyph_accessor() → GlyphAccessor | Returns 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) → Font | Returns a Font object converted to the target FontType |