feaLib: Read/write OpenType feature files
fontTools’ feaLib allows for the creation and parsing of Adobe
Font Development Kit for OpenType feature (.fea) files. The syntax
of these files is described here.
The fontTools.feaLib.parser.Parser class can be used to parse files
into an abstract syntax tree, and from there the
fontTools.feaLib.builder.Builder class can add features to an existing
font file. You can inspect the parsed syntax tree, walk the tree and do clever
things with it, and also generate your own feature files programmatically, by
using the classes in the fontTools.feaLib.ast module.
Parsing
- class fontTools.feaLib.parser.Parser(featurefile, glyphNames=(), followIncludes=True, includeDir=None, **kwargs)[source]
Initializes a Parser object.
Example
from fontTools.feaLib.parser import Parser parser = Parser(file, font.getReverseGlyphMap()) parsetree = parser.parse()
Note: the
glyphNamesiterable serves a double role to help distinguish glyph names from ranges in the presence of hyphens and to ensure that glyph names referenced in a feature file are actually part of a font’s glyph set. If the iterable is left empty, no glyph name in glyph set checking takes place, and all glyph tokens containing hyphens are treated as literal glyph names, not as ranges. (Adding a space around the hyphen can, in any case, help to disambiguate ranges from glyph names containing hyphens.)By default, the parser will follow
include()statements in the feature file. To turn this off, passfollowIncludes=False. Pass a directory string asincludeDirto explicitly declare a directory to search included feature files in.- parse()[source]
Parse the file, and return a
fontTools.feaLib.ast.FeatureFileobject representing the root of the abstract syntax tree containing the parsed contents of the file.
- parse_name_()[source]
Parses a name record. See section 9.e.
- parse_featureNames_(tag)[source]
Parses a
featureNamesstatement found in stylistic set features. See section 8.c.
- check_glyph_name_in_glyph_set(*names)[source]
Adds a glyph name (just start) or glyph names of a range (start and end) which are not in the glyph set to the “missing list” for future error reporting.
If no glyph set is present, does nothing.
Building
- fontTools.feaLib.builder.addOpenTypeFeatures(font, featurefile, tables=None, debug=False)[source]
Add features from a file to a font. Note that this replaces any features currently present.
- Parameters
font (feaLib.ttLib.TTFont) – The font object.
featurefile – Either a path or file object (in which case we parse it into an AST), or a pre-parsed AST instance.
tables – If passed, restrict the set of affected tables to those in the list.
debug – Whether to add source debugging information to the font in the
Debgtable
- fontTools.feaLib.builder.addOpenTypeFeaturesFromString(font, features, filename=None, tables=None, debug=False)[source]
Add features from a string to a font. Note that this replaces any features currently present.
- Parameters
font (feaLib.ttLib.TTFont) – The font object.
features – A string containing feature code.
filename – The directory containing
filenameis used as the root of relativeinclude()paths; ifNoneis provided, the current directory is assumed.tables – If passed, restrict the set of affected tables to those in the list.
debug – Whether to add source debugging information to the font in the
Debgtable
Generation/Interrogation
In the below, a glyph-containing object is an object of one of the following
classes: GlyphName, GlyphClass, GlyphClassName.
- class fontTools.feaLib.ast.Element(location=None)[source]
A base class representing “something” in a feature file.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.FeatureFile[source]
The top-level element of the syntax tree, containing the whole feature file in its
statementsattribute.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- build(builder)
When handed a ‘builder’ object of comparable interface to
fontTools.feaLib.builder, walks the statements in this block, calling the builder callbacks.
- statements
Statements contained in the block
- class fontTools.feaLib.ast.Comment(text, location=None)[source]
A comment in a feature file.
- text
Text of the comment
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.GlyphName(glyph, location=None)[source]
A single glyph name, such as
cedilla.- glyph
The name itself as a string
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.GlyphClass(glyphs=None, location=None)[source]
A glyph class, such as
[acute cedilla grave].- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- add_range(start, end, glyphs)[source]
Add a range (e.g.
A-Z) to the class.startandendare eitherGlyphNameobjects or strings representing the start and end glyphs in the class, andglyphsis the full list ofGlyphNameobjects in the range.
- add_cid_range(start, end, glyphs)[source]
Add a range to the class by glyph ID.
startandendare the initial and final IDs, andglyphsis the full list ofGlyphNameobjects in the range.
- add_class(gc)[source]
Add glyphs from the given
GlyphClassNameobject to the class.
- class fontTools.feaLib.ast.GlyphClassName(glyphclass, location=None)[source]
A glyph class name, such as
@FRENCH_MARKS. This must be instantiated with aGlyphClassDefinitionobject.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.MarkClassName(markClass, location=None)[source]
A mark class name, such as
@FRENCH_MARKSdefined withmarkClass. This must be instantiated with aMarkClassobject.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.AnonymousBlock(tag, content, location=None)[source]
An anonymous data block.
- tag
string containing the block’s “tag”
- content
block data as string
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.Block(location=None)[source]
A block of statements: feature, lookup, etc.
- statements
Statements contained in the block
- build(builder)[source]
When handed a ‘builder’ object of comparable interface to
fontTools.feaLib.builder, walks the statements in this block, calling the builder callbacks.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.FeatureBlock(name, use_extension=False, location=None)[source]
A named feature block.
- build(builder)[source]
Call the
start_featurecallback on the builder object, visit all the statements in this feature, and then callend_feature.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- statements
Statements contained in the block
- class fontTools.feaLib.ast.NestedBlock(tag, block_name, location=None)[source]
A block inside another block, for example when found inside a
cvParametersblock.- build(builder)[source]
When handed a ‘builder’ object of comparable interface to
fontTools.feaLib.builder, walks the statements in this block, calling the builder callbacks.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- statements
Statements contained in the block
- class fontTools.feaLib.ast.LookupBlock(name, use_extension=False, location=None)[source]
A named lookup, containing
statements.- build(builder)[source]
When handed a ‘builder’ object of comparable interface to
fontTools.feaLib.builder, walks the statements in this block, calling the builder callbacks.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- statements
Statements contained in the block
- class fontTools.feaLib.ast.GlyphClassDefinition(name, glyphs, location=None)[source]
Example:
@UPPERCASE = [A-Z];.- name
class name as a string, without initial
@
- glyphs
a
GlyphClassobject
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.GlyphClassDefStatement(baseGlyphs, markGlyphs, ligatureGlyphs, componentGlyphs, location=None)[source]
Example:
GlyphClassDef @UPPERCASE, [B], [C], [D];. The parameters must be eitherGlyphClassorGlyphClassNameobjects, orNone.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.MarkClass(name)[source]
One or more
markClassstatements for the same mark class.While glyph classes can be defined only once, the feature file format allows expanding mark classes with multiple definitions, each using different glyphs and anchors. The following are two
MarkClassDefinitionsfor the sameMarkClass:markClass [acute grave] <anchor 350 800> @FRENCH_ACCENTS; markClass [cedilla] <anchor 350 -200> @FRENCH_ACCENTS;
The
MarkClassobject is therefore just a container for a list ofMarkClassDefinitionstatements.- addDefinition(definition)[source]
Add a
MarkClassDefinitionstatement to this mark class.
- class fontTools.feaLib.ast.MarkClassDefinition(markClass, anchor, glyphs, location=None)[source]
A single
markClassstatement. ThemarkClassshould be aMarkClassobject, theanchoranAnchorobject, and theglyphsparameter should be a glyph-containing object .Example
mc = MarkClass("FRENCH_ACCENTS") mc.addDefinition( MarkClassDefinition(mc, Anchor(350, 800), GlyphClass([ GlyphName("acute"), GlyphName("grave") ]) ) ) mc.addDefinition( MarkClassDefinition(mc, Anchor(350, -200), GlyphClass([ GlyphName("cedilla") ]) ) ) mc.asFea() # markClass [acute grave] <anchor 350 800> @FRENCH_ACCENTS; # markClass [cedilla] <anchor 350 -200> @FRENCH_ACCENTS;
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.AlternateSubstStatement(prefix, glyph, suffix, replacement, location=None)[source]
A
sub ... from ...statement.prefix,glyph,suffixandreplacementshould be lists of glyph-containing objects.glyphshould be a one element list.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.Anchor(x, y, name=None, contourpoint=None, xDeviceTable=None, yDeviceTable=None, location=None)[source]
An
Anchorelement, used inside aposrule.If a
nameis given, this will be used in preference to the coordinates. Other values should be integer.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.AnchorDefinition(name, x, y, contourpoint=None, location=None)[source]
A named anchor definition. (2.e.viii).
nameshould be a string.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.AttachStatement(glyphs, contourPoints, location=None)[source]
A
GDEFtableAttachstatement.- glyphs
- contourPoints
A list of integer contour points
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.AxisValueLocationStatement(tag, values, location=None)[source]
A STAT table Axis Value Location
- Parameters
tag (str) – a 4 letter axis tag
values (list) – a list of ints and/or floats
- asFea(res='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.BaseAxis(bases, scripts, vertical, location=None)[source]
An axis definition, being either a
VertAxis.BaseTagList/BaseScriptListpair or aHorizAxis.BaseTagList/BaseScriptListpair.- bases
A list of baseline tag names as strings
- scripts
A list of script record tuplets (script tag, default baseline tag, base coordinate)
- vertical
Boolean; VertAxis if True, HorizAxis if False
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.CVParametersNameStatement(nameID, platformID, platEncID, langID, string, block_name, location=None)[source]
Represent a name statement inside a
cvParametersblock.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- nameID
Name ID as integer (e.g. 9 for designer’s name)
- platformID
Platform ID as integer
- platEncID
Platform encoding ID as integer
- langID
Language ID as integer
- string
Name record value
- class fontTools.feaLib.ast.ChainContextPosStatement(prefix, glyphs, suffix, lookups, location=None)[source]
A chained contextual positioning statement.
prefix,glyphs, andsuffixshould be lists of glyph-containing objects .lookupsshould be a list of elements representing what lookups to apply at each glyph position. Each element should be aLookupBlockto apply a single chaining lookup at the given position, a list ofLookupBlocks to apply multiple lookups, orNoneto apply no lookup. The length of the outer list should equal the length ofglyphs; the inner lists can be of variable length.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.ChainContextSubstStatement(prefix, glyphs, suffix, lookups, location=None)[source]
A chained contextual substitution statement.
prefix,glyphs, andsuffixshould be lists of glyph-containing objects .lookupsshould be a list of elements representing what lookups to apply at each glyph position. Each element should be aLookupBlockto apply a single chaining lookup at the given position, a list ofLookupBlocks to apply multiple lookups, orNoneto apply no lookup. The length of the outer list should equal the length ofglyphs; the inner lists can be of variable length.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.CharacterStatement(character, tag, location=None)[source]
Statement used in cvParameters blocks of Character Variant features (cvXX). The Unicode value may be written with either decimal or hexadecimal notation. The value must be preceded by ‘0x’ if it is a hexadecimal value. The largest Unicode value allowed is 0xFFFFFF.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.ConditionsetStatement(name, conditions, location=None)[source]
A variable layout conditionset
- Parameters
name (str) – the name of this conditionset
conditions (dict) – a dictionary mapping axis tags to a tuple of (min,max) userspace coordinates.
- asFea(res='', indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.CursivePosStatement(glyphclass, entryAnchor, exitAnchor, location=None)[source]
A cursive positioning statement. Entry and exit anchors can either be
Anchorobjects orNone.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.ElidedFallbackName(names, location=None)[source]
STAT table ElidedFallbackName
- Parameters
names – a list of
STATNameStatementobjects
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.ElidedFallbackNameID(value, location=None)[source]
STAT table ElidedFallbackNameID
- Parameters
value – an int pointing to an existing name table name ID
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.Expression(location=None)[source]
- asFea(indent='')
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.FeatureNameStatement(nameID, platformID, platEncID, langID, string, location=None)[source]
Represents a
sizemenunameornamestatement.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- nameID
Name ID as integer (e.g. 9 for designer’s name)
- platformID
Platform ID as integer
- platEncID
Platform encoding ID as integer
- langID
Language ID as integer
- string
Name record value
- class fontTools.feaLib.ast.FeatureReferenceStatement(featureName, location=None)[source]
Example:
feature salt;- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.FontRevisionStatement(revision, location=None)[source]
A
headtableFontRevisionstatement.revisionshould be a number, and will be formatted to three significant decimal places.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.HheaField(key, value, location=None)[source]
An entry in the
hheatable.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.IgnorePosStatement(chainContexts, location=None)[source]
An
ignore posstatement, containing one or more contexts to ignore.chainContextsshould be a list of(prefix, glyphs, suffix)tuples, with each ofprefix,glyphsandsuffixbeing glyph-containing objects .- build(builder)[source]
Calls the builder object’s
add_chain_context_poscallback on each rule context.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.IgnoreSubstStatement(chainContexts, location=None)[source]
An
ignore substatement, containing one or more contexts to ignore.chainContextsshould be a list of(prefix, glyphs, suffix)tuples, with each ofprefix,glyphsandsuffixbeing glyph-containing objects .- build(builder)[source]
Calls the builder object’s
add_chain_context_substcallback on each rule context.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.IncludeStatement(filename, location=None)[source]
An
include()statement.- filename
String containing name of file to include
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.LanguageStatement(language, include_default=True, required=False, location=None)[source]
A
languagestatement within a feature.- language
A four-character language tag
- include_default
If false, “exclude_dflt”
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.LanguageSystemStatement(script, language, location=None)[source]
A top-level
languagesystemstatement.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.LigatureCaretByIndexStatement(glyphs, carets, location=None)[source]
A
GDEFtableLigatureCaretByIndexstatement.glyphsshould be a glyph-containing object, andcaretsshould be a list of integers.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.LigatureCaretByPosStatement(glyphs, carets, location=None)[source]
A
GDEFtableLigatureCaretByPosstatement.glyphsshould be a glyph-containing object, andcaretsshould be a list of integers.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.LigatureSubstStatement(prefix, glyphs, suffix, replacement, forceChain, location=None)[source]
A chained contextual substitution statement.
prefix,glyphs, andsuffixshould be lists of glyph-containing objects;replacementshould be a single glyph-containing object.If
forceChainis True, this is expressed as a chaining rule (e.g.sub f' i' by f_i) even when no context is given.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.LookupFlagStatement(value=0, markAttachment=None, markFilteringSet=None, location=None)[source]
A
lookupflagstatement. Thevalueshould be an integer value representing the flags in use, but not including themarkAttachmentclass andmarkFilteringSetvalues, which must be specified as glyph-containing objects.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.LookupReferenceStatement(lookup, location=None)[source]
Represents a
lookup ...;statement to include a lookup in a feature.The
lookupshould be aLookupBlockobject.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.MarkBasePosStatement(base, marks, location=None)[source]
A mark-to-base positioning rule. The
baseshould be a glyph-containing object. Themarksshould be a list of (Anchor,MarkClass) tuples.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.MarkLigPosStatement(ligatures, marks, location=None)[source]
A mark-to-ligature positioning rule. The
ligaturesmust be a glyph-containing object. Themarksshould be a list of lists: each element in the top-level list represents a component glyph, and is made up of a list of (Anchor,MarkClass) tuples representing mark attachment points for that position.Example:
m1 = MarkClass("TOP_MARKS") m2 = MarkClass("BOTTOM_MARKS") # ... add definitions to mark classes... glyph = GlyphName("lam_meem_jeem") marks = [ [ (Anchor(625,1800), m1) ], # Attachments on 1st component (lam) [ (Anchor(376,-378), m2) ], # Attachments on 2nd component (meem) [ ] # No attachments on the jeem ] mlp = MarkLigPosStatement(glyph, marks) mlp.asFea() # pos ligature lam_meem_jeem <anchor 625 1800> mark @TOP_MARKS # ligComponent <anchor 376 -378> mark @BOTTOM_MARKS;
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.MarkMarkPosStatement(baseMarks, marks, location=None)[source]
A mark-to-mark positioning rule. The
baseMarksmust be a glyph-containing object. Themarksshould be a list of (Anchor,MarkClass) tuples.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.MultipleSubstStatement(prefix, glyph, suffix, replacement, forceChain=False, location=None)[source]
A multiple substitution statement.
- Parameters
prefix – a list of glyph-containing objects.
glyph – a single glyph-containing object.
suffix – a list of glyph-containing objects.
replacement – a list of glyph-containing objects.
forceChain – If true, the statement is expressed as a chaining rule (e.g.
sub f' i' by f_i) even when no context is given.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.NameRecord(nameID, platformID, platEncID, langID, string, location=None)[source]
Represents a name record. (Section 9.e.)
- nameID
Name ID as integer (e.g. 9 for designer’s name)
- platformID
Platform ID as integer
- platEncID
Platform encoding ID as integer
- langID
Language ID as integer
- string
Name record value
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.OS2Field(key, value, location=None)[source]
An entry in the
OS/2table. Mostvaluesshould be numbers or strings, apart from when the key isUnicodeRange,CodePageRangeorPanose, in which case it should be an array of integers.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.PairPosStatement(glyphs1, valuerecord1, glyphs2, valuerecord2, enumerated=False, location=None)[source]
A pair positioning statement.
glyphs1andglyphs2should be glyph-containing objects.valuerecord1should be aValueRecordobject;valuerecord2should be either aValueRecordobject orNone. Ifenumeratedis true, then this is expressed as an enumerated pair.- build(builder)[source]
Calls a callback on the builder object:
If the rule is enumerated, calls
add_specific_pair_poson each combination of first and second glyphs.If the glyphs are both single
GlyphNameobjects, callsadd_specific_pair_pos.Else, calls
add_class_pair_pos.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.ReverseChainSingleSubstStatement(old_prefix, old_suffix, glyphs, replacements, location=None)[source]
A reverse chaining substitution statement. You don’t see those every day.
Note the unusual argument order:
suffixcomes beforeglyphs.old_prefix,old_suffix,glyphsandreplacementsshould be lists of glyph-containing objects.glyphsandreplacementsshould be one-item lists.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.ScriptStatement(script, location=None)[source]
A
scriptstatement.- script
the script code
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.SinglePosStatement(pos, prefix, suffix, forceChain, location=None)[source]
A single position statement.
prefixandsuffixshould be lists of glyph-containing objects.posshould be a one-element list containing a (glyph-containing object,ValueRecord) tuple.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.SingleSubstStatement(glyphs, replace, prefix, suffix, forceChain, location=None)[source]
A single substitution statement.
Note the unusual argument order:
prefixand suffix come after the replacementglyphs.prefix,suffix,glyphsandreplaceshould be lists of glyph-containing objects.glyphsandreplaceshould be one-item lists.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.SizeParameters(DesignSize, SubfamilyID, RangeStart, RangeEnd, location=None)[source]
A
parametersstatement.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.Statement(location=None)[source]
- asFea(indent='')
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.STATAxisValueStatement(names, locations, flags, location=None)[source]
A STAT table Axis Value Record
- Parameters
names (list) – a list of
STATNameStatementobjectslocations (list) – a list of
AxisValueLocationStatementobjectsflags (int) – an int
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.STATDesignAxisStatement(tag, axisOrder, names, location=None)[source]
A STAT table Design Axis
- Parameters
tag (str) – a 4 letter axis tag
axisOrder (int) – an int
names (list) – a list of
STATNameStatementobjects
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.STATNameStatement(nameID, platformID, platEncID, langID, string, location=None)[source]
Represents a STAT table
namestatement.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- build(builder)
Calls the builder object’s
add_name_recordcallback.
- nameID
Name ID as integer (e.g. 9 for designer’s name)
- platformID
Platform ID as integer
- platEncID
Platform encoding ID as integer
- langID
Language ID as integer
- string
Name record value
- class fontTools.feaLib.ast.SubtableStatement(location=None)[source]
Represents a subtable break.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.TableBlock(name, location=None)[source]
A
table ... { }block.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- build(builder)
When handed a ‘builder’ object of comparable interface to
fontTools.feaLib.builder, walks the statements in this block, calling the builder callbacks.
- statements
Statements contained in the block
- class fontTools.feaLib.ast.ValueRecord(xPlacement=None, yPlacement=None, xAdvance=None, yAdvance=None, xPlaDevice=None, yPlaDevice=None, xAdvDevice=None, yAdvDevice=None, vertical=False, location=None)[source]
Represents a value record.
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.ValueRecordDefinition(name, value, location=None)[source]
Represents a named value record definition.
- name
Value record name as string
- value
ValueRecordobject
- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.
- class fontTools.feaLib.ast.VheaField(key, value, location=None)[source]
An entry in the
vheatable.- asFea(indent='')[source]
Returns this element as a string of feature code. For block-type elements (such as
FeatureBlock), the indent string is added to the start of each line in the output.