Converting features data between formats¶
The following modules help with converting font features information to and for different formats.
-
class
fontFeatures.feaLib.
FeaParser
(featurefile, font=None, glyphNames=None, includeDir=None)¶ Turns a AFDKO feature file or string into a FontFeatures object.
Parameters: - featurefile – File object or string.
- font – Optionally, a TTFont object.
- glyphNames – Optionally, a list of glyph names in the font
-
parse
()¶ Parse the feature code.
Returns: A FontFeatures
object containing the rules of this file.
ttLib: Interfacing with TrueType fonts.
This package contains routines for converting between fontTools objects (representing TrueType/OpenType fonts) and fontFeatures. This particular module is mainly concerned with getting information out of binary OTF/TTF fonts and into fontFeatures.
-
fontFeatures.ttLib.
unparse
(font, do_gdef=False, doLookups=True, config={})¶ Convert a binary OpenType font into a fontFeatures object
Parameters: - font – A
TTFont
object. - do_gdef – Boolean. Whether the GDEF table should also be read.
- doLookups – Whether the lookups should be read, or just the script/language information and top-level features.
- config – A dictionary of glyph class and routine names.
- font – A
-
fontFeatures.ttLib.
unparseLanguageSystems
(tables)¶ Build a set of script / language pairs from a GSUB/GPOS table.
Parameters: tables – A list of fontTools.ttLib.tables.G_S_U_B_.table_G_S_U_B_
/fontTools.ttLib.tables.G_P_O_S_.table_G_P_O_S_
objects.- Returns an ordered dictionary whose keys are four-character script tags and
- whose values are a set of four-character language tags.
-
class
fontFeatures.fontDameLib.
FontDameParser
(lines, config={}, glyphset=())¶ Convert layout files in Monotype’s FontDame format to fontFeatures.
Parameters: - lines – An array of strings containing the FontDame file, one line per string.
- config – A dictionary of glyph class names.
- glyphset – A list of glyph names in the font.
-
parse
()¶ Parses the font file, creating a fontFeatures object.
Returns: A fontFeatures object containing the rules in the FontDame file.