FL.objects.Font.Font

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

Bases: FakeFont

Base class to represent a font

__init__(font_or_path: Font | str | None = None, instances: tuple[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(weight_vector)

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_json])

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_global_mask(data)

fake_deserialize_guide_properties(data)

fake_deserialize_guides(data)

fake_deserialize_master_ps_infos()

fake_generate_primary_instances()

fake_get_afm([expand_kerning])

fake_get_afm_kerning([expand_kerning])

fake_get_inf()

fake_map_axis_location([axis_index, user_value])

fake_master_map()

fake_save_afm_expanded(filename)

fake_select(gid[, value])

Change selection status for glyph_index.

fake_serialize_axis()

fake_serialize_features()

fake_serialize_global_mask()

fake_serialize_guide_properties()

fake_serialize_guides()

fake_serialize_master_ps_infos()

fake_set_class_flags(flags)

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

fake_set_family_blues(values[, master_index])

Set the family blues values for a master.

fake_set_family_other_blues(values[, ...])

Set the family other blue values for a master.

fake_set_master_blue_values(values[, ...])

Set the blue values for a master.

fake_set_master_other_blues(values[, ...])

Set the other blues values for a master.

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

blue_fuzz

blue_scale

blue_shift

codepages

copyright

customdata

default_character

designer_url

designer

family_name

fond_id

font_name

font_style

full_name

hguides

is_fixed_pitch

italic_angle

mac_compatible

menu_name

modified

ms_charset

ms_id

note

notice

ot_classes

panose

pcl_chars_set

pcl_id

pref_family_name

pref_style_name

slant_angle

source

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

year

fake_vfb_object

ascender

axis

Array of font axes.

blue_values

Two-dimensional array of BlueValues.

blue_values_num

cap_height

classes

List of glyph classes.

default_width

descender

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

family_blues

Two-dimensional array of FamilyBlues.

family_blues_num

family_other_blues

Two-dimensional array of FamilyOtherBlues.

family_other_blues_num

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.

force_bold

List of Force Bold values, one for each master.

glyphs

Return the array of glyphs.

other_blues

Two-dimensional array of OtherBlues.

other_blues_num

stem_snap_h

stem_snap_h_num

stem_snap_v

stem_snap_v_num

truetypetables

List of custom TrueType tables.

vendor

x_height

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) – The axis name.

  • type (str) – The axis type: “OpticalSize”, “Serif”, “Weight”, or “Width”.

  • shortname (str) – The two-letter abbreviation.

DeleteAxis(axisindex: int, position: float) None

Removes the axis. Remaining masters will be blended according to the given position.

Parameters:
  • axisindex (int) – The index of the axis to remove (0 to 3).

  • position (float) – The position of the remaining masters on the removed axis.

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[int, int, int] | 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, save_json: bool = True) 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 blue_values: list[list[int]]

Two-dimensional array of BlueValues. Master index is top-level index.

Returns:

The blue values for all masters.

Return type:

list[list[int]]

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_set_family_blues(values: list[int], master_index: int = 0) None

Set the family blues values for a master.

Parameters:
  • values (list[int]) – The values.

  • master_index (int, optional) – The master index. Defaults to 0.

fake_set_family_other_blues(values: list[int], master_index: int = 0) None

Set the family other blue values for a master.

Parameters:
  • values (list[int]) – The values.

  • master_index (int, optional) – The master index. Defaults to 0.

fake_set_master_blue_values(values: list[int], master_index: int = 0) None

Set the blue values for a master.

Parameters:
  • values (list[int]) – The values.

  • master_index (int, optional) – The master index. Defaults to 0.

fake_set_master_other_blues(values: list[int], master_index: int = 0) None

Set the other blues values for a master.

Parameters:
  • values (list[int]) – The values.

  • master_index (int, optional) – The master index. Defaults to 0.

fake_update() None

Is called from FontLab.UpdateFont()

property family_blues: list[list[int]]

Two-dimensional array of FamilyBlues. Master index is top-level index.

Returns:

The family blues values for all masters.

Return type:

list[list[int]]

property family_other_blues: list[list[int]]

Two-dimensional array of FamilyOtherBlues. Master index is top-level index.

Returns:

The family other blues values for all masters.

Return type:

list[list[int]]

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 force_bold: list[int]

List of Force Bold values, one for each master.

Returns:

The Force Bold values.

Return type:

list[int]

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 other_blues: list[list[int]]

Two-dimensional array of OtherBlues. Master index is top-level index.

Returns:

The other blues values for all masters.

Return type:

list[list[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