FL.objects.Font.Font

class FL.objects.Font.Font(font_or_path: Font | str | None = None, instances: tuple[float, float, float, float] | None = None)

Bases: FakeFont

Base class to represent a font

__init__(font_or_path: Font | str | None = None, instances: tuple[float, float, float, float] | None = None) None

Methods

DefineAxis(name, type, shortname)

Defines a new Multiple Master axis.

DeleteAxis(axisindex, position)

Removes the axis

FindGlyph(name_uni_int)

(name: str) | (unicode: Uni) | (unicode: int) - finds glyph and return its index or -1

GenerateFont(fontType, filename)

Generate a font.

GenerateGlyph(name)

Generates new glyph using 'name' as a source of information about glyph's composition.

GenerateInstance()

GenerateNames()

Generates names for all glyphs

GenerateUnicode()

Generates Unicode indexes for all glyphs

GetClassLeft(class_index)

Return the 'left' property of the class.

GetClassMetricsFlags(class_index)

(int class_index) - returns the tuple containing LSB, RSB and Width flags of the metrics class

GetClassRight(class_index)

Return the 'right' property of the class.

MakeKernFeature(vector)

Generates 'kern' feature using font kerning and classes

MergeFonts(source[, flags])

Append all glyphs from the source font to the current fonts.

New()

Clear the font.

Open(filename)

Open a font from a VFB file.

OpenAFM(filename, mode, layer)

open AFM-File, mode is the integer bit field.

Reencode(e[, style])

Apply an encoding to the font.

Save(filename)

Save the font in VFB format.

SaveAFM(filename)

Save an AFM and an INF file.

SetClassFlags(class_index, left_lsb, right_rsb)

(int class_index, bool left, bool right) - allows to set 'left' and 'right' properties of the kerning class

__init__([font_or_path, instances])

fake_binary_from_path(fontType, file_path)

Assign a binary file from a path.

fake_binary_get(fontType)

fake_bounding_rect([for_afm])

fake_clear_defaults()

Clear some lists prior to deserializing a font from a Vfb.

fake_deselect_all()

Deselect all glyphs.

fake_deserialize_axis(data)

fake_deserialize_features(features)

fake_deserialize_guide_properties(data)

fake_deserialize_guides(data)

fake_get_afm([expand_kerning])

fake_get_afm_kerning([expand_kerning])

fake_get_inf()

fake_save_afm_expanded(filename)

fake_select(gid[, value])

Change selection status for glyph_index.

fake_serialize_axis()

fake_serialize_features()

fake_serialize_guide_properties()

fake_serialize_guides()

fake_set_class_flags(flags)

Set the kerning class flags from a list of str ("L", "R", "LR", ...)

fake_sort_glyphs(glyphs)

fake_sort_kerning(kerning)

fake_update()

Is called from FontLab.UpdateFont()

has_key(name_uni_int)

Find a glyph by name, unicode or integer unicode and return 1 (found) or 0 (not found).

Attributes

apple_name

ascender

blue_fuzz

blue_scale

blue_shift

blue_values_num

blue_values

cap_height

codepages

copyright

customdata

default_character

default_width

descender

designer_url

designer

family_blues_num

family_blues

family_name

family_other_blues_num

family_other_blues

fond_id

font_name

font_style

force_bold

full_name

hguides

is_fixed_pitch

italic_angle

mac_compatible

menu_name

modified

ms_charset

ms_id

note

notice

ot_classes

other_blues_num

other_blues

panose

pcl_chars_set

pcl_id

pref_family_name

pref_style_name

slant_angle

source

stem_snap_h_num

stem_snap_h

stem_snap_v_num

stem_snap_v

style_name

trademark

tt_u_id

tt_version

ttinfo

underline_position

underline_thickness

unicoderanges

unique_id

upm

vendor_url

version_major

version_minor

version

vguides

vp_id

weight_code

weight_vector

weight

width

x_height

year

fake_vfb_object

axis

Array of font axes.

classes

List of glyph classes.

encoding

Current encoding of the font.

fake_kerning

Returns the FL.fake.FakeKerning object, which can be used to manipulate the font's kerning data.

fake_sparse_json

features

List of Opentype features.

file_name

Full path of the file from which the font was opened/saved.

fontnames

List of font name records.

glyphs

Return the array of glyphs.

truetypetables

List of custom TrueType tables.

vendor

xuid

A list of Type 1 XUID numbers.

xuid_num

_summary_

DefineAxis(name: str, type: str, shortname: str) None

Defines a new Multiple Master axis.

Parameters:
  • name (str) – _description_

  • type (str) – _description_

  • shortname (str) – _description_

DeleteAxis(axisindex: int, position: float) None

Removes the axis

Parameters:
  • axisindex (int) – _description_

  • position (float) – _description_

FindGlyph(name_uni_int: str | Uni | int) int

(name: str) | (unicode: Uni) | (unicode: int) - finds glyph and return its index or -1

GenerateFont(fontType: int, filename: str) None

Generate a font. Deprecated. See the FL.objects.FontLab class for a description.

As a method of the Font class, this method is deprecated. Since FontLab 4.52 for Mac and FontLab 4.53 for Windows, GenerateFont is a method of the FontLab class.

Parameters:
  • fontType (int) – The font type.

  • filename (str) – The path and file name of the generated font.

Raises:

AttributeError – In FontLab 5, the method is deprecated.

GenerateGlyph(name: str) Glyph

Generates new glyph using ‘name’ as a source of information about glyph’s composition. See ‘FontLabDir/Mapping/alias.dat’ for composition definitions.

Parameters:

name (str) – _description_

Returns:

_description_

Return type:

Glyph

The glyph is not added to the font automatically.

GenerateNames() None

Generates names for all glyphs

GenerateUnicode() None

Generates Unicode indexes for all glyphs

GetClassLeft(class_index: int) int | None

Return the ‘left’ property of the class.

Parameters:

class_index (int) – _description_

Returns:

Returns 0 for non-kerning classes, 0 or 1 for kerning classes,

None for class_index outside the classes list length.

Return type:

int | None

GetClassMetricsFlags(class_index: int) tuple | None

(int class_index) - returns the tuple containing LSB, RSB and Width flags of the metrics class

GetClassRight(class_index: int) int | None

Return the ‘right’ property of the class.

Parameters:

class_index (int) – _description_

Returns:

Returns 0 for non-kerning classes, 0 or 1 for kerning classes,

None for class_index outside the classes list length.

Return type:

int | None

MakeKernFeature(vector: WeightVector) None

Generates ‘kern’ feature using font kerning and classes

Parameters:

vector (WeightVector) – The WeightVector used to interpolate the kerning values.

MergeFonts(source: Font, flags: int | None = None) None

Append all glyphs from the source font to the current fonts. Check mfXXXX constants for options.

Parameters:
  • source (Font) – The source font to be merged.

  • flags (int | None, optional) – _description_. Defaults to None.

New() None

Clear the font.

Open(filename: str) int

Open a font from a VFB file.

Parameters:

filename (str) – The path and file name of the VFB file.

Returns:

1 on success, 0 if the file could not be opened.

Return type:

int

If you need to import a font (not in VFB format), use FL.Open() or FL.OpenFont().

OpenAFM(filename: str, mode: int, layer: int) None
open AFM-File, mode is the integer bit field.

The bit list is: ALLMETRICS - 0x0001 THICKERMETRICS - 0x0002 WIDERMETRICS - 0x0004 CLOSEMETRICS - 0x0008 REPLACEKERNING - 0x0010 ADDKERNING - 0x0020 AUTOKERNING - 0x0040 REPLACEOTHERDATA - 0x0100 REPLACENAMES - 0x0200

Constants for mode (only in FL 4.5 Mac) mtALLMETRICS mtTHICKERMETRICS mtWIDERMETRIC mtCLOSEMETRICS mtREPLACEKERNING mtADDKERNING mtAUTOKERNING mtREPLACEOTHERDATA mtREPLACENAMES

Reencode(e: Encoding, style: int = 0) None

Apply an encoding to the font.

The parameters of this method are not reported by the docstring and I don’t know what the style parameter does.

Parameters:
  • e (Encoding) – The encoding.

  • style (int, optional) – _description_. Defaults to 0.

Save(filename: str) None

Save the font in VFB format.

Parameters:

filename (str) – The path and file name of the VFB file.

SaveAFM(filename: str) None

Save an AFM and an INF file.

Parameters:

filename (str) – The path and filename to save the files to.

SetClassFlags(class_index: int, left_lsb: bool | int, right_rsb: bool | int, width: bool | int | None = None) None

(int class_index, bool left, bool right) - allows to set ‘left’ and ‘right’ properties of the kerning class

(int class_index, bool lsb, bool rsb, bool width) - allows to set ‘lsb’, ‘rsb’ and ‘width’ properties of the metrics class

property axis: list[tuple[str, str, str]]

Array of font axes. Not reported by docstring nor e-font.

Example: [(‘Weight’, ‘Wt’, ‘Weight’)]

property classes: list[str]

List of glyph classes.

Returns a copy of the list. To change entries, you must reassign the whole list.

property encoding: Encoding

Current encoding of the font.

fake_binary_from_path(fontType: int, file_path: str) None

Assign a binary file from a path. This will be used to fake the FakeLab.GenerateFont() method.

fake_clear_defaults() None

Clear some lists prior to deserializing a font from a Vfb.

fake_deselect_all() None

Deselect all glyphs. Is called from FontLab.Unselect().

property fake_kerning: FakeKerning

Returns the FL.fake.FakeKerning object, which can be used to manipulate the font’s kerning data.

fake_select(gid: str | Uni | int, value: bool | None = None) None

Change selection status for glyph_index. >>> f = Font() >>> f.fake_select(1, False) >>> print(f._selection) set() >>> f.fake_select(1, True) >>> print(f._selection) {1} >>> f.fake_select(3, True) >>> print(f._selection) {1, 3} >>> f.fake_select(2, False) >>> print(f._selection) {1, 3} >>> f.fake_select(1, False) >>> print(f._selection) {3}

fake_set_class_flags(flags: list[str]) None

Set the kerning class flags from a list of str (“L”, “R”, “LR”, …)

fake_update() None

Is called from FontLab.UpdateFont()

property features: ListParent[Feature]

List of Opentype features.

property file_name: str

Full path of the file from which the font was opened/saved.

property fontnames: ListParent[NameRecord]

List of font name records.

property glyphs: ListParent[Glyph]

Return the array of glyphs.

has_key(name_uni_int: str | Uni | int) int

Find a glyph by name, unicode or integer unicode and return 1 (found) or 0 (not found).

Parameters:

name_uni_int (str | Uni | int) – _description_

Returns:

1 if the glyph name or unicode value are present in the font,

0 otherwise.

Return type:

int

property truetypetables: ListParent[TrueTypeTable]

List of custom TrueType tables.

property xuid: list[int]

A list of Type 1 XUID numbers.

The list may contain from 0 to 20 entries. To change the length of the list, set Font.xuid_num.

Returns:

The list of Type 1 XUID numbers.

Return type:

list[int]

property xuid_num: int

_summary_

Returns:

_description_

Return type:

int