The foundrytools.core.tables module contains classes for handling fontTools.ttLib.tables
objects.
Each table wrapper provides a set of methods for accessing and modifying the table data.
from foundrytools import Font
font = Font("path/to/font.otf")
font.t_cff_.round_coordinates()
font.os_2.recalc_unicode_ranges()
Wrapped tables are accessible via the table property of the table wrapper.
from foundrytools import Font
font = Font("path/to/font.otf")
# Access the wrapped ``fontTools.ttLib.tables._c_m_a_p.table__c_m_a_p`` object
font.t_cmap.table.buildReversed()
foundrytools.core.tables.cff_ module
- class foundrytools.core.tables.cff_.CFFTable(ttfont: TTFont)[source]
Bases:
DefaultTblA class that wraps and manages the CFF table of a font, providing methods to manipulate hinting data, font names, and glyph contours.
- _set_cff_font_names(font_name: str) None[source]
Sets the
cff.fontNamesvalue.- Parameters:
font_name (str) – The font name to set.
- _set_top_dict_names(names: dict[str, str]) None[source]
Sets the names of the
CFFtable.- Parameters:
names (dict[str, str]) – The names to set.
- correct_contours(remove_hinting: bool = True, ignore_errors: bool = True, remove_unused_subroutines: bool = True, min_area: int = 25, drop_hinting_data: bool = False) set[str][source]
Corrects contours of the CFF table by removing overlaps, correcting the direction of the contours, and removing tiny paths.
- Parameters:
remove_hinting (bool) – Whether to remove hinting from the font if one or more glyphs are modified.
ignore_errors (bool) – Whether to ignore skia pathops errors while correcting contours.
remove_unused_subroutines (bool) – Whether to remove unused subroutines from the font.
min_area (int) – The minimum area of a contour to be considered. Default is 25.
drop_hinting_data (bool) – If True, the hinting data will be removed from the font.
- Returns:
A set of glyph names that were modified.
- Return type:
set[str]
- del_names(**kwargs: dict[str, str]) None[source]
Deletes names from
topDictIndex[0]using the provided keyword arguments.- Parameters:
kwargs (dict[str, str]) – The names to delete from the
CFFtableTopDict.
- find_replace(old_string: str, new_string: str) None[source]
Find and replace a string in the
CFFtable.- Parameters:
old_string (str) – The string to find.
new_string (str) – The string to replace the old string with.
- get_hinting_data() dict[str, Any][source]
Returns the hinting data from the
CFFtable.- Returns:
The hinting data.
- Return type:
dict[str, Any]
- property private_dict: PrivateDict
Returns the private field of the
CFFtable.- Returns:
The private field of the
CFFtable.- Return type:
PrivateDict
- remove_hinting(drop_hinting_data: bool = False) None[source]
Removes hinting data from a PostScript font.
- Parameters:
drop_hinting_data (bool) – If True, the hinting data will be removed from the font.
- round_coordinates(drop_hinting_data: bool = False) set[str][source]
Round the coordinates of the font’s glyphs using the
RoundingPen.- Returns:
A set of glyph names whose coordinates were rounded.
- Return type:
set[str]
- set_hinting_data(**kwargs: dict[str, Any]) None[source]
Sets the hinting data in the
CFFtable.- Parameters:
kwargs (dict[str, Any]) – The hinting data to set.
- set_names(**kwargs: dict[str, str]) None[source]
Sets the
cff.fontNames[0]andtopDictIndex[0]values.- Parameters:
kwargs (dict[str, str]) – The values to set in the CFF table.
- property table: table_C_F_F_
The wrapped
table_C_F_F_object.
- property top_dict: TopDict
Returns the topDictIndex field of the
CFFtable.- Returns:
The topDictIndex field of the
CFFtable.- Return type:
TopDict
foundrytools.core.tables.cmap module
- class foundrytools.core.tables.cmap.CmapTable(ttfont: TTFont)[source]
Bases:
DefaultTblThis class extends the fontTools
cmaptable.- add_missing_nbsp() None[source]
Fixes the missing non-breaking space glyph by double mapping the space glyph.
- get_all_codepoints() set[int][source]
Returns all the codepoints in the
cmaptable.- Returns:
A set of codepoints
- Return type:
set[int]
- get_unmapped_glyphs() list[str][source]
Returns all the unmapped glyphs in the
cmaptable.- Returns:
A set of glyph names
- Return type:
set[str]
- property is_modified: bool
Returns whether the
cmaptable has been modified.- Returns:
Whether the
cmaptable has been modified.- Return type:
bool
- rebuild_character_map(remap_all: bool = False) tuple[list[tuple[int, str]], list[tuple[int, str, str]]][source]
Rebuild the character map of the font.
- Parameters:
remap_all (bool) – Whether to remap all glyphs. If
False, only the unmapped glyphs will be remapped.- Returns:
A tuple containing the remapped and duplicate glyphs.
- Return type:
tuple[list[tuple[int, str]], list[tuple[int, str, str]]]
- property table: table__c_m_a_p
The wrapped
table__c_m_a_ptable object.
foundrytools.core.tables.default module
- class foundrytools.core.tables.default.DefaultTbl(ttfont: TTFont, table_tag: str)[source]
Bases:
Generic[T]Manages font table data with functionality for detecting modifications and setting bits.
This class allows you to interact with a specific table in a font’s data to determine if the table has been modified and to set specific bits within the table’s fields.
- property is_modified: bool
Checks if the table has been modified.
By default, we assume that when the table has been accessed, it has been modified. Subclasses should override this method to provide a more accurate check.
- Returns:
True
- Return type:
bool
- set_bit(field_name: str, pos: int, value: bool) None[source]
Sets a specific bit in a field of the table.
- Parameters:
field_name (str) – The field name.
pos (int) – The position of the bit to set.
value (bool) – The value to set.
- property table: T
Thw wrapped table object.
- property ttfont: TTFont
Returns the
TTFontobject to which the table belongs.- Returns:
The TTFont object.
- Return type:
TTFont
foundrytools.core.tables.fvar module
- class foundrytools.core.tables.fvar.FvarTable(ttfont: TTFont)[source]
Bases:
DefaultTblThis class extends the fontTools
fvartable.- property table: table__f_v_a_r
Thw wrapped
table__f_v_a_rtable object.
foundrytools.core.tables.gdef module
- class foundrytools.core.tables.gdef.GdefTable(ttfont: TTFont)[source]
Bases:
DefaultTblThis class is a wrapper for the
GDEFtable.- property table: table_G_D_E_F_
The wrapped
table_G_D_E_F_table object.
foundrytools.core.tables.glyf module
- class foundrytools.core.tables.glyf.GlyfTable(ttfont: TTFont)[source]
Bases:
DefaultTblThis class extends the fontTools
glyftable.- correct_contours(remove_hinting: bool = True, ignore_errors: bool = True, min_area: int = 25) set[str][source]
Corrects contours of the glyf table by removing overlaps, correcting the direction of the contours, and removing tiny paths.
- Parameters:
remove_hinting (bool) – Whether to remove hinting from the font if one or more glyphs are modified.
ignore_errors (bool) – Whether to ignore skia pathops errors while correcting contours.
min_area (int) – The minimum area of a contour to be considered. Default is 25.
- Returns:
A set of glyph names that were modified.
- Return type:
set[str]
- decompose_all() set[str][source]
Decompose all composite glyphs.
- Returns:
A set of glyph names that were decomposed
- Return type:
set[str]
- decompose_glyph(glyph_name: str) None[source]
Decompose the components of a given glyph name.
- Parameters:
glyph_name (str) – The name of the glyph to decompose.
- decompose_transformed() set[str][source]
Decompose composite glyphs that have transformed components.
- remove_duplicate_components() set[str][source]
Remove duplicate components from composite glyphs.
- Returns:
A set of glyph names that were fixed.
- Return type:
set[str]
- property table: table__g_l_y_f
Thw wrapped
table__g_l_y_ftable object.
foundrytools.core.tables.gsub module
- class foundrytools.core.tables.gsub.GsubTable(ttfont: TTFont)[source]
Bases:
DefaultTblThis class extends the fontTools
GSUBtable.- get_feature_tags() set[str][source]
Returns a list of all the feature tags in the font’s GSUB table.
- Returns:
The feature tags.
- Return type:
list[str]
- get_ui_name_ids() set[int][source]
Returns a set of all the UI name IDs in the font’s GSUB table.
- Returns:
The UI name IDs.
- Return type:
set[int]
- remap_ui_name_ids(name_ids_map: dict[int, int]) None[source]
Remap the UI name IDs in the GSUB table.
- Parameters:
name_ids_map (dict[int, int]) – A dictionary with the old and new UI name IDs.
- rename_feature(feature_tag: str, new_feature_tag: str) bool[source]
Rename a GSUB feature.
- Example:
>>> from foundrytools import Font >>> font = Font("path/to/font.ttf") >>> font.t_gsub.rename_feature("smcp", "ss20") >>> font.save("path/to/font.ttf")
- Parameters:
feature_tag (str) – The feature tag to rename.
new_feature_tag (str) – The new feature tag.
- Returns:
True if the feature was renamed, False otherwise.
- Return type:
bool
- property table: table_G_S_U_B_
The wrapped
table_G_S_U_B_table object.
foundrytools.core.tables.head module
- class foundrytools.core.tables.head.HeadTable(ttfont: TTFont)[source]
Bases:
DefaultTblThis class extends the fontTools
headtable.- property created_timestamp: int
A property with getter and setter for the
createdfield of theheadtable.- Returns:
The created timestamp.
- Return type:
int
- property font_revision: float
A property with getter and setter for the
fontRevisionfield of theheadtable.- Returns:
The font revision value.
- Return type:
float
- property is_modified: bool
A property that returns True if the
headtable has been modified, False otherwise.- Returns:
True if the
headtable has been modified, False otherwise.- Return type:
bool
- property modified_timestamp: int
A property with getter and setter for the
modifiedfield of theheadtable.- Returns:
The modified timestamp.
- Return type:
int
- property table: table__h_e_a_d
The wrapped
table__h_e_a_dtable object.
- property units_per_em: int
A read-only property for the
unitsPerEmfield of theheadtable.- Returns:
The units per em value.
- Return type:
int
- property x_max: int
A property with getter and setter for the
xMaxfield of theheadtable.- Returns:
The
xMaxvalue.- Return type:
int
- property x_min: int
A property with getter and setter for the
xMinfield of theheadtable.- Returns:
The
xMinvalue.- Return type:
int
- property y_max: int
A property with getter and setter for the
yMaxfield of theheadtable.- Returns:
The
yMaxvalue.- Return type:
int
- property y_min: int
A property with getter and setter for the
yMinfield of theheadtable.- Returns:
The
yMinvalue.- Return type:
int
- class foundrytools.core.tables.head.MacStyle(head_table: HeadTable)[source]
Bases:
objectA wrapper class for the
macStylefield of theheadtable.- property bold: bool
A property with getter and setter for bit 0 (BOLD) in the
macStylefield of theheadtable.- Returns:
True if bit 0 is set, False otherwise.
- Return type:
bool
- property italic: bool
A property with getter and setter for bit 1 (ITALIC) in the
macStylefield of theheadtable.- Returns:
True if bit 1 is set, False otherwise.
- Return type:
bool
foundrytools.core.tables.hhea module
- class foundrytools.core.tables.hhea.HheaTable(ttfont: TTFont)[source]
Bases:
DefaultTblThis class extends the fontTools
hheatables.- property advance_width_max: int
A property with getter and setter for the
advanceWidthMaxfield of thehheatable.- Returns:
The
advanceWidthMaxvalue.- Return type:
int
- property ascent: int
A property with getter and setter for the
ascentfield of thehheatable.- Returns:
The
ascentvalue.- Return type:
int
- calc_caret_slope_rise(italic_angle: int | float | None = None) int[source]
Calculate the
caretSlopeRisefield of thehheatable.- Parameters:
italic_angle (Optional[Union[int, float]]) – The italic to use for the calculation. If
None, the italic angle from theposttable will be used.- Returns:
The caret slope rise value.
- Return type:
int
- calc_caret_slope_run(italic_angle: int | float | None = None) int[source]
Calculate the
caretSlopeRunfield of thehheatable.- Parameters:
italic_angle (Optional[Union[int, float]]) – The italic to use for the calculation. If
None, the italic angle from theposttable will be used.- Returns:
The caret slope run value.
- Return type:
int
- property caret_offset: int
A property with getter and setter for the
caretOffsetfield of thehheatable.- Returns:
The
caretOffsetvalue.- Return type:
int
- property caret_slope_rise: int
A property with getter and setter for the
caretSlopeRisefield of thehheatable.- Returns:
The
caretSlopeRisevalue.- Return type:
int
- property caret_slope_run: int
A property with getter and setter for the
caretSlopeRunfield of thehheatable.- Returns:
The
caretSlopeRunvalue.- Return type:
int
- property descent: int
A property with getter and setter for the
descentfield of thehheatable.- Returns:
The
descentvalue.- Return type:
int
- property is_modified: bool
A read-only property that returns whether the
hheatable has been modified.- Returns:
Whether the
hheatable has been modified.- Return type:
bool
- property line_gap: int
A property with getter and setter for the
lineGapfield of thehheatable.- Returns:
The
lineGapvalue.- Return type:
int
- property metric_data_format: int
A read-only property for the
metricDataFormatfield of thehheatable.- Returns:
The
metricDataFormatvalue.- Return type:
int
- property min_left_side_bearing: int
A read-only property for the
minLeftSideBearingfield of thehheatable.- Returns:
The
minLeftSideBearingvalue.- Return type:
int
- property min_right_side_bearing: int
A read-only property for the
minRightSideBearingfield of thehheatable.- Returns:
The
minRightSideBearingvalue.- Return type:
int
- property number_of_hmetrics: int
A read-only property for the
numberOfHMetricsfield of thehheatable.- Returns:
The
numberOfHMetricsvalue.- Return type:
int
- property run_rise_angle: float
Calculate the slope angle by dividing the caret slope run by the caret slope rise.
- Returns:
The slope angle in degrees.
- Return type:
float
- property table: table__h_h_e_a
The wrapped
table__h_h_e_atable object.
- property x_max_extent: int
A read-only property for the
xMaxExtentfield of thehheatable.- Returns:
The
xMaxExtentvalue.- Return type:
int
foundrytools.core.tables.hmtx module
- class foundrytools.core.tables.hmtx.HmtxTable(ttfont: TTFont)[source]
Bases:
DefaultTblThis class extends the fontTools
hmtxtable.- fix_non_breaking_space_width() bool[source]
Sets the width of the non-breaking space glyph to be the same as the space glyph.
- Raises:
ValueError – If the space or non-breaking space glyphs do not exist.
- property table: table__h_m_t_x
The wrapped
table__h_m_t_xtable object.
foundrytools.core.tables.kern module
foundrytools.core.tables.name module
- class foundrytools.core.tables.name.NameTable(ttfont: TTFont)[source]
Bases:
DefaultTblThis class extends the fontTools
nametable.- _get_name_ids_for_filter(name_ids_to_process: Iterable | None = None, name_ids_to_skip: Iterable | None = None) set[int][source]
Returns a set of name IDs to be used for filtering.
- append_prefix_suffix(name_ids: tuple[int], platform_id: int | None = None, language_string: str | None = None, prefix: str | None = None, suffix: str | None = None) None[source]
Appends a prefix, a suffix, or both to the NameRecords that match the nameID, platformID, and language string.
- Parameters:
name_ids (tuple[int]) – A tuple of name IDs to process.
platform_id (Optional[int]) – The platform ID of the name records to process. Defaults to None, which means that NameRecords from all platforms are processed. If 1, only NameRecords with platformID 1 (Macintosh) are processed. If 3, only NameRecords with platformID 3 (Windows) are processed.
language_string (Optional[str]) – The language of the name records to process. Defaults to None, which means that NameRecords in all languages are processed.
prefix (Optional[str]) – The prefix to append to the NameRecords. Defaults to None.
suffix – The suffix to append to the NameRecords. Defaults to None.
- build_full_font_name(platform_id: int | None = None) None[source]
Build the NameID 4 (Full Font Name) record based on the family name and subfamily name.
- Parameters:
platform_id (Optional[int]) – The platform ID of the name record. Defaults to None. If None, the NameRecord is added to both platforms. If 1, the NameRecord is added to the Macintosh platform. If 3, the NameRecord is added to the Windows platform.
- build_mac_names() None[source]
Build the Macintosh-specific NameRecords 1 (Font Family Name), 2 (Font Subfamily Name), 4 (Full Font Name), 5 (Version String), and 6 (PostScript Name).
- build_postscript_name(platform_id: int | None = None) None[source]
Build the NameID 6 (PostScript Name) record based on the PostScript name.
- Parameters:
platform_id (Optional[int]) – The platform ID of the name record. Defaults to None. If None, the NameRecord is added to both platforms. If 1, the NameRecord is added to the Macintosh platform. If 3, the NameRecord is added to the Windows platform.
- build_unique_identifier(platform_id: int | None = None, alternate: bool = False) None[source]
Build the NameID 3 (Unique Font Identifier) record based on the font revision, vendor ID, and PostScript name.
- Parameters:
platform_id (Optional[int]) – The platform ID of the name record. Defaults to None. If None, the NameRecord is added to both platforms. If 1, the NameRecord is added to the Macintosh platform. If 3, the NameRecord is added to the Windows platform.
alternate (bool) – Whether to build an alternate unique identifier. Defaults to False. If False, the unique identifier is built based on the font revision, vendor ID, and PostScript name. If True, the unique identifier is built based on the manufacturer name, family name, subfamily name, and year created.
- build_version_string(platform_id: int | None = None) None[source]
Build the NameID 5 (Version String) record based on the font revision.
- Parameters:
platform_id (Optional[int]) – The platform ID of the name record. Defaults to None. If None, the NameRecord is added to both platforms. If 1, the NameRecord is added to the Macintosh platform. If 3, the NameRecord is added to the Windows platform.
- filter_names(name_ids: set[int] | None = None, platform_id: int | None = None, plat_enc_id: int | None = None, lang_id: int | None = None, lang_string: str | None = None) list[NameRecord][source]
Filters NameRecords based on the given parameters.
- Parameters:
name_ids (Optional[set[int]]) – A set of NameIDs to filter. Defaults to None, which means that all NameIDs are filtered.
platform_id (Optional[int]) – The platform ID of the NameRecords to filter. Defaults to None, which means that NameRecords from all platforms are filtered. If 1, only NameRecords with platformID 1 (Macintosh) are filtered. If 3, only NameRecords with platformID 3 (Windows) are filtered.
plat_enc_id (Optional[int]) – The platform encoding ID of the NameRecords to filter. Defaults to None, which means that NameRecords from all platform encoding IDs are filtered.
lang_id (Optional[int]) – The language ID of the NameRecords to filter. Defaults to None, which means that NameRecords from all languages are filtered.
lang_string (Optional[str]) – The language string of the NameRecords to filter. Defaults to None, which means that NameRecords from all languages are filtered.
- Returns:
The filtered NameRecords.
- Return type:
list[NameRecord]
- find_replace(old_string: str, new_string: str, name_ids_to_process: tuple[int] | None = None, name_ids_to_skip: tuple[int] | None = None, platform_id: int | None = None) None[source]
Finds and replaces occurrences of a string in the specified NameRecords of the
nametable of a font.- Parameters:
old_string (str) – The string to find.
new_string (str) – The string to replace the old string with.
name_ids_to_process (Optional[tuple[int]]) – A tuple of name IDs to process. Defaults to None, which means that all name IDs are processed.
name_ids_to_skip (Optional[tuple[int]]) – A tuple of name IDs to skip. Defaults to None, which means that no name IDs are skipped.
platform_id (Optional[int]) – The platform ID of the name records to process. Defaults to None, which means that NameRecords from all platforms are processed. If 1, only NameRecords with platformID 1 (Macintosh) are processed. If 3, only NameRecords with platformID 3 (Windows) are processed.
- get_best_family_name() str[source]
Returns the best family name from the
nametable. The best family name is converted to string to handle cases where the family name is None.- Returns:
The best family name.
- Return type:
str
- get_best_subfamily_name() str[source]
Returns the best subfamily name from the
nametable. The best subfamily name is converted to string to handle cases where the subfamily name is None.- Returns:
The best subfamily name.
- Return type:
str
- get_debug_name(name_id: int) str[source]
Returns the NameRecord string with the specified NameID. The NameRecord is converted to string to handle cases where the NameRecord is None.
- Parameters:
name_id (int) – The NameID of the NameRecord.
- Returns:
The debug name of the NameRecord.
- Return type:
str
- property is_modified: bool
Compiles the original and current
nametables and compares them to determine if the table has been modified.- Returns:
Whether the
nametable has been modified.- Return type:
bool
- remove_names(name_ids: Iterable[int], platform_id: int | None = None, language_string: str | None = None) None[source]
Deletes the specified NameRecords from the
nametable of a font.- Parameters:
name_ids (Iterable[int]) – A list of NameIDs to remove.
platform_id (Optional[int]) – The platform ID of the NameRecords to remove. Defaults to None, which means that NameRecords from all platforms are removed. If 1, only NameRecords with platformID 1 (Macintosh) are removed. If 3, only NameRecords with platformID 3 (Windows) are removed.
language_string (Optional[str]) – The language of the NameRecords to remove. Defaults to None, which means that NameRecords in all languages are removed.
- set_name(name_id: int, name_string: str, platform_id: int | None = None, language_string: str = 'en') None[source]
Adds a NameRecord to the
nametable of a font.- Parameters:
name_id (int) – The NameID of the NameRecord.
name_string (str) – The string to add to the NameRecord.
platform_id (Optional[int]) – The platform ID of the NameRecord. Defaults to None. If None, the NameRecord is added to both platforms. If 1, the NameRecord is added to the Macintosh platform. If 3, the NameRecord is added to the Windows platform.
language_string (str) – The language of the NameRecord. Defaults to “en”.
- strip_names() None[source]
Removes leading and trailing spaces from all NameRecords in the
nametable.
- property table: table__n_a_m_e
The wrapped
table__n_a_m_etable object.
foundrytools.core.tables.os_2 module
- class foundrytools.core.tables.os_2.FsSelection(os_2_table: OS2Table)[source]
Bases:
objectA wrapper class for the
fsSelectionfield of theOS/2table.- property bold: bool
A property with getter and setter for bit 5 (BOLD) in the
OS/2.fsSelectionfield.- Returns:
True if bit 5 is set, False otherwise.
- Return type:
bool
- property italic: bool
A property with getter and setter for bit 0 (ITALIC) in the
OS/2.fsSelectionfield.- Returns:
True if bit 0 is set, False otherwise.
- Return type:
bool
- property negative: bool
A property with getter and setter for bit 2 (NEGATIVE) in the
OS/2.fsSelectionfield.- Returns:
True if bit 2 is set, False otherwise.
- Return type:
bool
- property oblique: bool
A property with getter and setter for bit 9 (OBLIQUE) in the
OS/2.fsSelectionfield.- Returns:
True if bit 9 is set, False otherwise.
- Return type:
bool
- property outlined: bool
A property with getter and setter for bit 3 (OUTLINED) in the
OS/2.fsSelectionfield.- Returns:
True if bit 3 is set, False otherwise.
- Return type:
bool
- property regular: bool
A property with getter and setter for bit 6 (REGULAR) in the
OS/2.fsSelectionfield.- Returns:
True if bit 6 is set, False otherwise.
- Return type:
bool
- property strikeout: bool
A property with getter and setter for bit 4 (STRIKEOUT) in the
OS/2.fsSelectionfield.- Returns:
True if bit 4 is set, False otherwise.
- Return type:
bool
- property underscore: bool
A property with getter and setter for bit 1 (UNDERSCORE) in the
OS/2.fsSelectionfield.- Returns:
True if bit 1 is set, False otherwise.
- Return type:
bool
- property use_typo_metrics: bool
A property with getter and setter for bit 7 (USE_TYPO_METRICS) in the
OS/2.fsSelection- Returns:
True if bit 7 is set, False otherwise.
- Return type:
bool
- property wws_consistent: bool
A property with getter and setter for bit 8 (WWS) in the
OS/2.fsSelectionfield.- Returns:
True if bit 8 is set, False otherwise.
- Return type:
bool
- exception foundrytools.core.tables.os_2.InvalidOS2VersionError[source]
Bases:
ExceptionException raised when trying to access a field that is not defined in the current OS/2 table version.
- class foundrytools.core.tables.os_2.OS2Table(ttfont: TTFont)[source]
Bases:
DefaultTblThis class extends the fontTools
OS/2table.- property bitmap_embed_only: bool
A property with getter and setter for bit 9 (BITMAP_EMBED_ONLY) in the
OS/2.fsTypefield.- Returns:
True if bit 9 is set, False otherwise.
- Return type:
bool
- property cap_height: int | None
A property with getter and setter for the
OS/2.sCapHeightfield.sCapHeightis only defined in OS/2 table versions 2 and up.- Returns:
The
OS/2.sCapHeightvalue.- Return type:
int
- property codepage_ranges: set[int]
A property with getter and setter for the
OS/2.ulCodePageRange(1-2)fields.- Returns:
The code page ranges of the
OS/2table.- Return type:
set[int]
- property embed_level: int
A property with getter and setter for the embedding level of the
OS/2.fsTypefield.The value can be 0, 2, 4 or 8.
0: Installable Embedding
2: Restricted License Embedding
4: Preview & Print Embedding
8: Editable Embedding
- property is_modified: bool
A property that returns True if the OS/2 table has been modified.
- Returns:
True if the OS/2 table has been modified, False otherwise.
- Return type:
bool
- property max_context: int | None
A property with getter and setter for the
OS/2.usMaxContextfield.usMaxContextis only defined in OS/2 table versions 2 and up.- Returns:
The
OS/2.usMaxContextvalue.- Return type:
int
- property no_subsetting: bool
A property with getter and setter for bit 8 (NO_SUBSETTING) in the
OS/2.fsTypefield.- Returns:
True if bit 8 is set, False otherwise.
- Return type:
bool
- recalc_avg_char_width() int[source]
Recalculates the
OS/2.xAvgCharWidthvalue.- Returns:
The new
OS/2.xAvgCharWidthvalue.- Return type:
int
- recalc_unicode_ranges(percentage: float = 33.0) set[tuple[int, str, str]][source]
Recalculates the
OS/2.ulUnicodeRange(1-4)fields.- Parameters:
percentage (float) – The percentage of codepoints that must be present in a Unicode block for it to be enabled. Default is 33.0.
- Returns:
A set of tuples with the modified Unicode ranges.
- Return type:
set[tuple[int, str, str]]
- Raises:
KeyError: If the font does not have a cmap table.
- property table: table_O_S_2f_2
The wrapped
table_O_S_2f_2table object.
- property typo_ascender: int
A property with getter and setter for the
OS/2.sTypoAscenderfield.- Returns:
The
OS/2.sTypoAscendervalue.- Return type:
int
- property typo_descender: int
A property with getter and setter for the
OS/2.sTypoDescenderfield.- Returns:
The
OS/2.sTypoDescendervalue.- Return type:
int
- property typo_line_gap: int
A property with getter and setter for the
OS/2.sTypoLineGapfield.- Returns:
The
OS/2.sTypoLineGapvalue.- Return type:
int
- property unicode_ranges: set[int]
A property with getter and setter for the
OS/2.ulUnicodeRange(1-4)fields.- Returns:
The Unicode ranges of the
OS/2table.- Return type:
set[int]
- upgrade(target_version: int) None[source]
Upgrades the
OS/2table to a more recent version.- Parameters:
target_version (int) – The target version to upgrade to.
- Raises:
InvalidOS2VersionError: If the target version is less than the current version.
- property us_break_char: int | None
A property with getter and setter for the
OS/2.usBreakCharfield.- Returns:
The
OS/2.usBreakCharvalue.- Return type:
int
- property us_default_char: int | None
A property with getter and setter for the
OS/2.usDefaultCharfield.- Returns:
The
OS/2.usDefaultCharvalue.- Return type:
int
- property us_lower_optical_point_size: int | None
A property with getter and setter for the
OS/2.usLowerOpticalPointSizefield.- Returns:
The
OS/2.usLowerOpticalPointSizevalue.- Return type:
int
- property us_upper_optical_point_size: int | None
A property with getter and setter for the
OS/2.usUpperOpticalPointSizefield.- Returns:
The
OS/2.usUpperOpticalPointSizevalue.- Return type:
int
- property vendor_id: str
A property with getter and setter for the
OS/2.achVendIDfield.When setting the property value, it is padded with spaces to a length of 4.
- Returns:
The
OS/2.achVendIDvalue.- Return type:
str
- property version: int
A property with getter and setter for the
OS/2.versionfield.Valid values are between 0 and 5.
- Returns:
The
OS/2.versionvalue.- Return type:
int
- property weight_class: int
A property with getter and setter for the
OS/2.usWeightClassfield.The value can be an integer between 1 and 1000.
- Returns:
The
OS/2.usWeightClassvalue.- Return type:
int
- property width_class: int
A property with getter and setter for the
OS/2.usWidthClassfield.The value can be an integer between 1 and 9.
- Returns:
The
OS/2.usWidthClassvalue.- Return type:
int
- property win_ascent: int
A property with getter and setter for the
OS/2.usWinAscentfield.- Returns:
The
OS/2.usWinAscentvalue.- Return type:
int
- property win_descent: int
A property with getter and setter for the
OS/2.usWinDescentfield.- Returns:
The
OS/2.usWinDescentvalue.- Return type:
int
- property x_height: int | None
A property with getter and setter for the
OS/2.sxHeightfield.sxHeightis only defined inOS/2table versions 2 and up.- Returns:
The
OS/2.sxHeightvalue.- Return type:
int
foundrytools.core.tables.post module
- class foundrytools.core.tables.post.PostTable(ttfont: TTFont)[source]
Bases:
DefaultTblThis class extends the fontTools
posttable.- property fixed_pitch: bool
A property with getter and setter for the
post.isFixedPitchfield.- Returns:
The isFixedPitch value.
- Return type:
bool
- property is_modified: bool
Checks if the table has been modified.
- Returns:
True if the table has been modified, False otherwise.
- Return type:
bool
- property italic_angle: float
A property with getter and setter for the
post.italicAnglefield.- Returns:
The italic angle value.
- Return type:
float
- property table: table__p_o_s_t
The wrapped
table__p_o_s_ttable object.
- property underline_position: int
A property with getter and setter for the
post.underlinePositionfield.- Returns:
The underline position value.
- Return type:
int
- property underline_thickness: int
A property with getter and setter for the
post.underlineThicknessfield.- Returns:
The underline thickness value.
- Return type:
int