AuthoredFont
Overview
AuthoredFont is a class in Aspose.PDF FOSS for Python.
A normalized embedded font and the mutable CID mapping for authored text.
This class provides 8 methods for working with AuthoredFont objects in Python programs.
Available methods include: __init__, cid_to_gid_bytes, cid_widths, embedded_program, encode, encode_glyph, glyph_id, to_unicode_cmap.
All public members are accessible to any Python application after installing the Aspose.PDF FOSS for Python package.
Properties: base_name, cid_font_subtype, descriptor_metrics, fingerprint, font_file_key, font_file_subtype, and 3 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
base_name | str | Read | Return the exact current PDF BaseFont/FontName value. |
pdf_base_name | str | Read | Alias for :attr:base_name used by COS integration code. |
is_subset | bool | Read | Whether :meth:embedded_program currently returns a reduced font. |
descriptor_metrics | dict[str, int | float | tuple[int, int, int, int]] | Read | Return PDF FontDescriptor metrics using PDF dictionary key names. |
shaping_program | bytes | Read | Return the complete SFNT program used by the shaping engine. |
fingerprint | `` | Read | Gets the fingerprint. |
cid_font_subtype | `` | Read | Gets the cid font subtype. |
font_file_key | `` | Read | Gets the font file key. |
font_file_subtype | `` | Read | Gets the font file subtype. |
Methods
| Signature | Description |
|---|---|
__init__(sfnt_program: bytes, embedded_program: bytes, plain_base_name: str, kind: str, unicode_to_gid: dict[int, int], metrics: _SfntMetrics, gid_to_native_cid: dict[int, int] | None) | Calls init(sfnt_program, embedded_program, plain_base_name, kind, unicode_to_gid, metrics, gid_to_native_cid) on this AuthoredFont instance. |
glyph_id(character: str) → int | None | Return the cmap glyph ID for one Unicode character, if available. |
encode(text: str) → bytes | Encode text as two-byte CIDs and extend the current font mapping. |
encode_glyph(gid: int, unicode_text: str) → bytes | Assign a CID to one shaped glyph and its logical Unicode cluster. |
embedded_program() → bytes | Return the current embedded program, subset when it becomes smaller. |
to_unicode_cmap() → bytes | Build a ToUnicode CMap for the current two-byte CID assignments. |
cid_widths() → dict[int, int] | Return current CID -> advance widths in 1000-unit PDF space. |
cid_to_gid_bytes() → bytes | None | Return a CIDToGIDMap stream for TrueType, or None for CFF. |