feaLib¶
fontTools.feaLib – a package for dealing with OpenType feature files.
ast¶
-
class
fontTools.feaLib.ast.
AlternateSubstStatement
(prefix, glyph, suffix, replacement, location=None)[source]¶
-
class
fontTools.feaLib.ast.
Anchor
(x, y, name=None, contourpoint=None, xDeviceTable=None, yDeviceTable=None, location=None)[source]¶
-
class
fontTools.feaLib.ast.
BytesIO
¶ Buffered I/O implementation using an in-memory bytes buffer.
-
close
()¶ Disable all I/O operations.
-
closed
¶ True if the file is closed.
-
flush
()¶ Does nothing.
-
getbuffer
()¶ Get a read-write view over the contents of the BytesIO object.
-
getvalue
()¶ Retrieve the entire contents of the BytesIO object.
-
isatty
()¶ Always returns False.
BytesIO objects are not connected to a TTY-like device.
-
read
()¶ Read at most size bytes, returned as a bytes object.
If the size argument is negative, read until EOF is reached. Return an empty bytes object at EOF.
-
read1
()¶ Read at most size bytes, returned as a bytes object.
If the size argument is negative or omitted, read until EOF is reached. Return an empty bytes object at EOF.
-
readable
()¶ Returns True if the IO object can be read.
-
readinto
()¶ Read bytes into buffer.
Returns number of bytes read (0 for EOF), or None if the object is set not to block and has no data to read.
-
readline
()¶ Next line from the file, as a bytes object.
Retain newline. A non-negative size argument limits the maximum number of bytes to return (an incomplete line may be returned then). Return an empty bytes object at EOF.
-
readlines
()¶ List of bytes objects, each a line from the file.
Call readline() repeatedly and return a list of the lines so read. The optional size argument, if given, is an approximate bound on the total number of bytes in the lines returned.
-
seek
()¶ Change stream position.
- Seek to byte offset pos relative to position indicated by whence:
- 0 Start of stream (the default). pos should be >= 0; 1 Current position - pos may be negative; 2 End of stream - pos usually negative.
Returns the new absolute position.
-
seekable
()¶ Returns True if the IO object can be seeked.
-
tell
()¶ Current file position, an integer.
-
truncate
()¶ Truncate the file to at most size bytes.
Size defaults to the current file position, as returned by tell(). The current file position is unchanged. Returns the new size.
-
writable
()¶ Returns True if the IO object can be written.
-
write
()¶ Write bytes to file.
Return the number of bytes written.
-
writelines
()¶ Write lines to the file.
Note that newlines are not added. lines can be any iterable object producing bytes-like objects. This is equivalent to calling write() for each element.
-
-
class
fontTools.feaLib.ast.
CVParametersNameStatement
(nameID, platformID, platEncID, langID, string, block_name, location=None)[source]¶
-
class
fontTools.feaLib.ast.
ChainContextPosStatement
(prefix, glyphs, suffix, lookups, location=None)[source]¶
-
class
fontTools.feaLib.ast.
ChainContextSubstStatement
(prefix, glyphs, suffix, lookups, location=None)[source]¶
-
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.
-
class
fontTools.feaLib.ast.
CursivePosStatement
(glyphclass, entryAnchor, exitAnchor, location=None)[source]¶
-
class
fontTools.feaLib.ast.
FeatureNameStatement
(nameID, platformID, platEncID, langID, string, location=None)[source]¶
-
class
fontTools.feaLib.ast.
FeatureReferenceStatement
(featureName, location=None)[source]¶ Example: feature salt;
-
class
fontTools.feaLib.ast.
GlyphClass
(glyphs=None, location=None)[source]¶ A glyph class, such as [acute cedilla grave].
-
class
fontTools.feaLib.ast.
GlyphClassDefStatement
(baseGlyphs, markGlyphs, ligatureGlyphs, componentGlyphs, location=None)[source]¶ Example: GlyphClassDef @UPPERCASE, [B], [C], [D];
-
class
fontTools.feaLib.ast.
GlyphClassDefinition
(name, glyphs, location=None)[source]¶ Example: @UPPERCASE = [A-Z];
-
class
fontTools.feaLib.ast.
GlyphClassName
(glyphclass, location=None)[source]¶ A glyph class name, such as @FRENCH_MARKS.
-
class
fontTools.feaLib.ast.
GlyphName
(glyph, location=None)[source]¶ A single glyph name, such as cedilla.
-
class
fontTools.feaLib.ast.
LanguageStatement
(language, include_default=True, required=False, location=None)[source]¶
-
class
fontTools.feaLib.ast.
LigatureSubstStatement
(prefix, glyphs, suffix, replacement, forceChain, location=None)[source]¶
-
class
fontTools.feaLib.ast.
LookupFlagStatement
(value=0, markAttachment=None, markFilteringSet=None, location=None)[source]¶
-
class
fontTools.feaLib.ast.
MarkClassName
(markClass, location=None)[source]¶ A mark class name, such as @FRENCH_MARKS defined with markClass.
-
class
fontTools.feaLib.ast.
MultipleSubstStatement
(prefix, glyph, suffix, replacement, forceChain=False, location=None)[source]¶
-
class
fontTools.feaLib.ast.
NameRecord
(nameID, platformID, platEncID, langID, string, location=None)[source]¶
-
class
fontTools.feaLib.ast.
OrderedDict
[source]¶ Dictionary that remembers insertion order
-
clear
() → None. Remove all items from od.¶
-
copy
() → a shallow copy of od¶
-
fromkeys
()¶ Create a new ordered dictionary with keys from iterable and values set to value.
-
items
() → a set-like object providing a view on D's items¶
-
keys
() → a set-like object providing a view on D's keys¶
-
move_to_end
()¶ Move an existing element to the end (or beginning if last is false).
Raise KeyError if the element does not exist.
-
pop
(k[, d]) → v, remove specified key and return the corresponding¶ value. If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem
()¶ Remove and return a (key, value) pair from the dictionary.
Pairs are returned in LIFO order if last is true or FIFO order if false.
-
setdefault
()¶ Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
-
update
([E, ]**F) → None. Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
-
values
() → an object providing a view on D's values¶
-
-
class
fontTools.feaLib.ast.
PairPosStatement
(glyphs1, valuerecord1, glyphs2, valuerecord2, enumerated=False, location=None)[source]¶
-
class
fontTools.feaLib.ast.
ReverseChainSingleSubstStatement
(old_prefix, old_suffix, glyphs, replacements, location=None)[source]¶
-
class
fontTools.feaLib.ast.
SimpleNamespace
¶ A simple attribute-based namespace.
SimpleNamespace(**kwargs)
-
class
fontTools.feaLib.ast.
SinglePosStatement
(pos, prefix, suffix, forceChain, location=None)[source]¶
-
class
fontTools.feaLib.ast.
SingleSubstStatement
(glyphs, replace, prefix, suffix, forceChain, location=None)[source]¶
-
class
fontTools.feaLib.ast.
SizeParameters
(DesignSize, SubfamilyID, RangeStart, RangeEnd, location=None)[source]¶
-
class
fontTools.feaLib.ast.
StringIO
¶ Text I/O implementation using an in-memory buffer.
The initial_value argument sets the value of object. The newline argument is like the one of TextIOWrapper’s constructor.
-
close
()¶ Close the IO object.
Attempting any further operation after the object is closed will raise a ValueError.
This method has no effect if the file is already closed.
-
closed
¶
-
getvalue
()¶ Retrieve the entire contents of the object.
-
line_buffering
¶
-
newlines
¶ Line endings translated so far.
Only line endings translated during reading are considered.
Subclasses should override.
-
read
()¶ Read at most size characters, returned as a string.
If the argument is negative or omitted, read until EOF is reached. Return an empty string at EOF.
-
readable
()¶ Returns True if the IO object can be read.
-
readline
()¶ Read until newline or EOF.
Returns an empty string if EOF is hit immediately.
-
seek
()¶ Change stream position.
- Seek to character offset pos relative to position indicated by whence:
- 0 Start of stream (the default). pos should be >= 0; 1 Current position - pos must be 0; 2 End of stream - pos must be 0.
Returns the new absolute position.
-
seekable
()¶ Returns True if the IO object can be seeked.
-
tell
()¶ Tell the current file position.
-
truncate
()¶ Truncate size to pos.
The pos argument defaults to the current file position, as returned by tell(). The current file position is unchanged. Returns the new absolute position.
-
writable
()¶ Returns True if the IO object can be written.
-
write
()¶ Write string to file.
Returns the number of characters written, which is always equal to the length of the string.
-
-
fontTools.feaLib.ast.
UnicodeIO
¶ alias of
_io.StringIO
-
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]¶
builder¶
-
class
fontTools.feaLib.builder.
Builder
(font, featurefile)[source]¶ -
-
add_to_cv_num_named_params
(tag)[source]¶ Adds new items to self.cv_num_named_params_ or increments the count of existing items.
-
find_lookup_builders_
(lookups)[source]¶ Helper for building chain contextual substitutions
Given a list of lookup names, finds the LookupBuilder for each name. If an input name is None, it gets mapped to a None LookupBuilder.
-
supportedTables
= frozenset({'BASE', 'name', 'head', 'GSUB', 'vhea', 'GPOS', 'OS/2', 'GDEF', 'hhea'})¶
-
-
class
fontTools.feaLib.builder.
ClassPairPosSubtableBuilder
(builder, valueFormat1, valueFormat2)[source]¶
-
class
fontTools.feaLib.builder.
LookupBuilder
(font, location, table, lookup_type)[source]¶ -
SUBTABLE_BREAK_
= 'SUBTABLE_BREAK'¶
-
error¶
-
class
fontTools.feaLib.parser.
Parser
(featurefile, glyphNames=(), followIncludes=True, **kwargs)[source]¶ -
CV_FEATURE_TAGS
= {'cv01', 'cv02', 'cv03', 'cv04', 'cv05', 'cv06', 'cv07', 'cv08', 'cv09', 'cv10', 'cv11', 'cv12', 'cv13', 'cv14', 'cv15', 'cv16', 'cv17', 'cv18', 'cv19', 'cv20', 'cv21', 'cv22', 'cv23', 'cv24', 'cv25', 'cv26', 'cv27', 'cv28', 'cv29', 'cv30', 'cv31', 'cv32', 'cv33', 'cv34', 'cv35', 'cv36', 'cv37', 'cv38', 'cv39', 'cv40', 'cv41', 'cv42', 'cv43', 'cv44', 'cv45', 'cv46', 'cv47', 'cv48', 'cv49', 'cv50', 'cv51', 'cv52', 'cv53', 'cv54', 'cv55', 'cv56', 'cv57', 'cv58', 'cv59', 'cv60', 'cv61', 'cv62', 'cv63', 'cv64', 'cv65', 'cv66', 'cv67', 'cv68', 'cv69', 'cv70', 'cv71', 'cv72', 'cv73', 'cv74', 'cv75', 'cv76', 'cv77', 'cv78', 'cv79', 'cv80', 'cv81', 'cv82', 'cv83', 'cv84', 'cv85', 'cv86', 'cv87', 'cv88', 'cv89', 'cv90', 'cv91', 'cv92', 'cv93', 'cv94', 'cv95', 'cv96', 'cv97', 'cv98', 'cv99'}¶
-
SS_FEATURE_TAGS
= {'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'ss07', 'ss08', 'ss09', 'ss10', 'ss11', 'ss12', 'ss13', 'ss14', 'ss15', 'ss16', 'ss17', 'ss18', 'ss19', 'ss20'}¶
-
ast
= <module 'fontTools.feaLib.ast' from '/build/fonttools-eQQ8BD/fonttools-4.5.0/Doc/source/../../Lib/fontTools/feaLib/ast.py'>¶
-
check_glyph_name_in_glyph_set
(*names)[source]¶ Raises if glyph name (just start) or glyph names of a range (start and end) are not in the glyph set.
If no glyph set is present, does nothing.
-
extensions
= {}¶
-
make_cid_range_
(location, start, limit)[source]¶ (location, 999, 1001) –> [“cid00999”, “cid01000”, “cid01001”]
-
make_glyph_range_
(location, start, limit)[source]¶ (location, “a.sc”, “d.sc”) –> [“a.sc”, “b.sc”, “c.sc”, “d.sc”]
-
parse_glyphclass_definition_
()[source]¶ Parses glyph class definitions such as ‘@UPPERCASE = [A-Z];’
-
lexer¶
-
class
fontTools.feaLib.lexer.
Lexer
(text, filename)[source]¶ -
ANONYMOUS_BLOCK
= 'ANONYMOUS_BLOCK'¶
-
CHAR_DIGIT_
= '0123456789'¶
-
CHAR_HEXDIGIT_
= '0123456789ABCDEFabcdef'¶
-
CHAR_LETTER_
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'¶
-
CHAR_NAME_CONTINUATION_
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.+*:^~!/-'¶
-
CHAR_NAME_START_
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_+*:.^~!\\'¶
-
CHAR_NEWLINE_
= '\r\n'¶
-
CHAR_SYMBOL_
= ",;:-+'{}[]<>()="¶
-
CHAR_WHITESPACE_
= ' \t'¶
-
CID
= 'CID'¶
-
COMMENT
= 'COMMENT'¶
-
FILENAME
= 'FILENAME'¶
-
FLOAT
= 'FLOAT'¶
-
GLYPHCLASS
= 'GLYPHCLASS'¶
-
HEXADECIMAL
= 'HEXADECIMAL'¶
-
MODE_FILENAME_
= 'FILENAME'¶
-
MODE_NORMAL_
= 'NORMAL'¶
-
NAME
= 'NAME'¶
-
NEWLINE
= 'NEWLINE'¶
-
NUMBER
= 'NUMBER'¶
-
NUMBERS
= ('NUMBER', 'HEXADECIMAL', 'OCTAL')¶
-
OCTAL
= 'OCTAL'¶
-
RE_GLYPHCLASS
= re.compile('^[A-Za-z_0-9.\\-]+$')¶
-
STRING
= 'STRING'¶
-
SYMBOL
= 'SYMBOL'¶
-
parser¶
-
class
fontTools.feaLib.parser.
Parser
(featurefile, glyphNames=(), followIncludes=True, **kwargs)[source] -
CV_FEATURE_TAGS
= {'cv01', 'cv02', 'cv03', 'cv04', 'cv05', 'cv06', 'cv07', 'cv08', 'cv09', 'cv10', 'cv11', 'cv12', 'cv13', 'cv14', 'cv15', 'cv16', 'cv17', 'cv18', 'cv19', 'cv20', 'cv21', 'cv22', 'cv23', 'cv24', 'cv25', 'cv26', 'cv27', 'cv28', 'cv29', 'cv30', 'cv31', 'cv32', 'cv33', 'cv34', 'cv35', 'cv36', 'cv37', 'cv38', 'cv39', 'cv40', 'cv41', 'cv42', 'cv43', 'cv44', 'cv45', 'cv46', 'cv47', 'cv48', 'cv49', 'cv50', 'cv51', 'cv52', 'cv53', 'cv54', 'cv55', 'cv56', 'cv57', 'cv58', 'cv59', 'cv60', 'cv61', 'cv62', 'cv63', 'cv64', 'cv65', 'cv66', 'cv67', 'cv68', 'cv69', 'cv70', 'cv71', 'cv72', 'cv73', 'cv74', 'cv75', 'cv76', 'cv77', 'cv78', 'cv79', 'cv80', 'cv81', 'cv82', 'cv83', 'cv84', 'cv85', 'cv86', 'cv87', 'cv88', 'cv89', 'cv90', 'cv91', 'cv92', 'cv93', 'cv94', 'cv95', 'cv96', 'cv97', 'cv98', 'cv99'}
-
SS_FEATURE_TAGS
= {'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'ss07', 'ss08', 'ss09', 'ss10', 'ss11', 'ss12', 'ss13', 'ss14', 'ss15', 'ss16', 'ss17', 'ss18', 'ss19', 'ss20'}
-
advance_lexer_
(comments=False)[source]
-
ast
= <module 'fontTools.feaLib.ast' from '/build/fonttools-eQQ8BD/fonttools-4.5.0/Doc/source/../../Lib/fontTools/feaLib/ast.py'>
-
check_glyph_name_in_glyph_set
(*names)[source] Raises if glyph name (just start) or glyph names of a range (start and end) are not in the glyph set.
If no glyph set is present, does nothing.
-
expect_any_number_
()[source]
-
expect_cid_
()[source]
-
expect_class_name_
()[source]
-
expect_decipoint_
()[source]
-
expect_filename_
()[source]
-
expect_float_
()[source]
-
expect_glyph_
()[source]
-
expect_keyword_
(keyword)[source]
-
expect_language_tag_
()[source]
-
expect_markClass_reference_
()[source]
-
expect_name_
()[source]
-
expect_number_
()[source]
-
expect_script_tag_
()[source]
-
expect_string_
()[source]
-
expect_symbol_
(symbol)[source]
-
expect_tag_
()[source]
-
extensions
= {}
-
is_cur_keyword_
(k)[source]
-
is_next_value_
()[source]
-
make_cid_range_
(location, start, limit)[source] (location, 999, 1001) –> [“cid00999”, “cid01000”, “cid01001”]
-
make_glyph_range_
(location, start, limit)[source] (location, “a.sc”, “d.sc”) –> [“a.sc”, “b.sc”, “c.sc”, “d.sc”]
-
parse
()[source]
-
parse_FontRevision_
()[source]
-
parse_GlyphClassDef_
()[source] Parses ‘GlyphClassDef @BASE, @LIGATURES, @MARKS, @COMPONENTS;’
-
parse_anchor_
()[source]
-
parse_anchor_marks_
()[source] Parses a sequence of [<anchor> mark @MARKCLASS]*.
-
parse_anchordef_
()[source]
-
parse_anonymous_
()[source]
-
parse_attach_
()[source]
-
parse_base_script_list_
(count)[source]
-
parse_base_script_record_
(count)[source]
-
parse_base_tag_list_
()[source]
-
parse_block_
(block, vertical, stylisticset=None, size_feature=False, cv_feature=None)[source]
-
parse_chain_context_
()[source]
-
parse_class_name_
()[source]
-
parse_cvCharacter_
(tag)[source]
-
parse_cvNameIDs_
(tag, block_name)[source]
-
parse_cvParameters_
(tag)[source]
-
parse_device_
()[source]
-
parse_enumerate_
(vertical)[source]
-
parse_featureNames_
(tag)[source]
-
parse_feature_block_
()[source]
-
parse_feature_reference_
()[source]
-
parse_glyph_pattern_
(vertical)[source]
-
parse_glyphclass_
(accept_glyphname)[source]
-
parse_glyphclass_definition_
()[source] Parses glyph class definitions such as ‘@UPPERCASE = [A-Z];’
-
parse_ignore_
()[source]
-
parse_include_
()[source]
-
parse_language_
()[source]
-
parse_languagesystem_
()[source]
-
parse_ligatureCaretByIndex_
()[source]
-
parse_ligatureCaretByPos_
()[source]
-
parse_lookup_
(vertical)[source]
-
parse_lookupflag_
()[source]
-
parse_markClass_
()[source]
-
parse_name_
()[source]
-
parse_nameid_
()[source]
-
parse_position_
(enumerated, vertical)[source]
-
parse_position_base_
(enumerated, vertical)[source]
-
parse_position_cursive_
(enumerated, vertical)[source]
-
parse_position_ligature_
(enumerated, vertical)[source]
-
parse_position_mark_
(enumerated, vertical)[source]
-
parse_script_
()[source]
-
parse_size_menuname_
()[source]
-
parse_size_parameters_
()[source]
-
parse_substitute_
()[source]
-
parse_subtable_
()[source]
-
parse_table_
()[source]
-
parse_table_BASE_
(table)[source]
-
parse_table_GDEF_
(table)[source]
-
parse_table_OS_2_
(table)[source]
-
parse_table_head_
(table)[source]
-
parse_table_hhea_
(table)[source]
-
parse_table_name_
(table)[source]
-
parse_table_vhea_
(table)[source]
-
parse_valuerecord_
(vertical)[source]
-
parse_valuerecord_definition_
(vertical)[source]
-
static
reverse_string_
(s)[source] ‘abc’ –> ‘cba’
-
split_glyph_range_
(name, location)[source]
-
static
unescape_byte_
(match, encoding)[source]
-
unescape_string_
(string, encoding)[source]
-
static
unescape_unichr_
(match)[source]
-