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:
FakeFontBase 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()Generates names for all glyphs
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])Clear some lists prior to deserializing a font from a Vfb.
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)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_nameascenderblue_fuzzblue_scaleblue_shiftblue_values_numblue_valuescap_heightcodepagescopyrightcustomdatadefault_characterdefault_widthdescenderdesigner_urldesignerfamily_blues_numfamily_bluesfamily_namefamily_other_blues_numfamily_other_bluesfond_idfont_namefont_styleforce_boldfull_namehguidesis_fixed_pitchitalic_anglemac_compatiblemenu_namemodifiedms_charsetms_idnotenoticeot_classesother_blues_numother_bluespanosepcl_chars_setpcl_idpref_family_namepref_style_nameslant_anglesourcestem_snap_h_numstem_snap_hstem_snap_v_numstem_snap_vstyle_nametrademarktt_u_idtt_versionttinfounderline_positionunderline_thicknessunicoderangesunique_idupmvendor_urlversion_majorversion_minorversionvguidesvp_idweight_codeweight_vectorweightwidthx_heightyearfake_vfb_objectArray of font axes.
List of glyph classes.
Current encoding of the font.
Returns the FL.fake.FakeKerning object, which can be used to manipulate the font's kerning data.
fake_sparse_jsonList of Opentype features.
Full path of the file from which the font was opened/saved.
List of font name records.
Return the array of glyphs.
List of custom TrueType tables.
vendorA list of Type 1 XUID numbers.
_summary_
- 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:
- 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.
The glyph is not added to the font automatically.
- GetClassMetricsFlags(class_index: int) tuple | None
(int class_index) - returns the tuple containing LSB, RSB and Width flags of the metrics class
- 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.
- 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:
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.
- 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.
- 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.
- 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”, …)
- property features: ListParent[Feature]
List of Opentype features.
- 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).
- property truetypetables: ListParent[TrueTypeTable]
List of custom TrueType tables.