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
([buffer]) → object¶ Create a buffered I/O implementation using an in-memory bytes buffer, ready for reading and writing.
-
close
() → None. Disable all I/O operations.¶
-
closed
¶ True if the file is closed.
-
flush
() → None. Does nothing.¶
-
getvalue
() → bytes.¶ Retrieve the entire contents of the BytesIO object.
-
isatty
() → False.¶ Always returns False since BytesIO objects are not connected to a tty-like device.
-
next
¶
-
read
([size]) → read at most size bytes, returned as a string.¶ If the size argument is negative, read until EOF is reached. Return an empty string at EOF.
-
read1
(size) → read at most size bytes, returned as a string.¶ If the size argument is negative or omitted, read until EOF is reached. Return an empty string at EOF.
-
readable
() → bool. Returns True if the IO object can be read.¶
-
readinto
(b) → int. Read up to len(b) bytes into b.¶ 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
([size]) → next line from the file, as a string.¶ 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 string at EOF.
-
readlines
([size]) → list of strings, 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
(pos[, whence]) → int. 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
() → bool. Returns True if the IO object can be seeked.¶
-
tell
() → current file position, an integer¶
-
truncate
([size]) → int. 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
() → bool. Returns True if the IO object can be written.¶
-
write
(bytes) → int. Write bytes to file.¶ Return the number of bytes written.
-
writelines
(sequence_of_strings) → None. Write strings to the file.¶ Note that newlines are not added. The sequence can be any iterable object producing strings. This is equivalent to calling write() for each string.
-
-
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
(**kwds)[source]¶ Dictionary that remembers insertion order
-
classmethod
fromkeys
(S[, v]) → New ordered dictionary with keys from S.[source]¶ If not specified, the value defaults to None.
-
pop
(k[, d]) → v, remove specified key and return the corresponding[source]¶ value. If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem
() → (k, v), return and remove a (key, value) pair.[source]¶ Pairs are returned in LIFO order if last is true or FIFO order if false.
-
update
([E, ]**F) → None. Update D from mapping/iterable E and F.¶ If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
-
classmethod
-
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
(**kwargs)[source]¶ A backport of Python 3.3’s
types.SimpleNamespace
.
-
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
(buf='')[source]¶ class StringIO([buffer])
When a StringIO object is created, it can be initialized to an existing string by passing the string to the constructor. If no string is given, the StringIO will start empty.
The StringIO object can accept either Unicode or 8-bit strings, but mixing the two may take some care. If both are used, 8-bit strings that cannot be interpreted as 7-bit ASCII (that use the 8th bit) will cause a UnicodeError to be raised when getvalue() is called.
-
getvalue
()[source]¶ Retrieve the entire contents of the “file” at any time before the StringIO object’s close() method is called.
The StringIO object can accept either Unicode or 8-bit strings, but mixing the two may take some care. If both are used, 8-bit strings that cannot be interpreted as 7-bit ASCII (that use the 8th bit) will cause a UnicodeError to be raised when getvalue() is called.
-
next
()[source]¶ A file object is its own iterator, for example iter(f) returns f (unless f is closed). When a file is used as an iterator, typically in a for loop (for example, for line in f: print line), the next() method is called repeatedly. This method returns the next input line, or raises StopIteration when EOF is hit.
-
read
(n=-1)[source]¶ Read at most size bytes from the file (less if the read hits EOF before obtaining size bytes).
If the size argument is negative or omitted, read all data until EOF is reached. The bytes are returned as a string object. An empty string is returned when EOF is encountered immediately.
-
readline
(length=None)[source]¶ Read one entire line from the file.
A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). If the size argument is present and non-negative, it is a maximum byte count (including the trailing newline) and an incomplete line may be returned.
An empty string is returned only when EOF is encountered immediately.
Note: Unlike stdio’s fgets(), the returned string contains null characters (‘0’) if they occurred in the input.
-
readlines
(sizehint=0)[source]¶ Read until EOF using readline() and return a list containing the lines thus read.
If the optional sizehint argument is present, instead of reading up to EOF, whole lines totalling approximately sizehint bytes (or more to accommodate a final whole line).
-
seek
(pos, mode=0)[source]¶ Set the file’s current position.
The mode argument is optional and defaults to 0 (absolute file positioning); other values are 1 (seek relative to the current position) and 2 (seek relative to the file’s end).
There is no return value.
-
truncate
(size=None)[source]¶ Truncate the file’s size.
If the optional size argument is present, the file is truncated to (at most) that size. The size defaults to the current position. The current file position is not changed unless the position is beyond the new file size.
If the specified size exceeds the file’s current size, the file remains unchanged.
-
-
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(['GDEF', 'head', 'name', 'OS/2', 'GSUB', 'BASE', 'vhea', 'GPOS', 'hhea'])¶
-
-
class
fontTools.feaLib.builder.
ClassPairPosSubtableBuilder
(builder, valueFormat1, valueFormat2)[source]¶
-
class
fontTools.feaLib.builder.
LookupBuilder
(font, location, table, lookup_type)[source]¶ -
SUBTABLE_BREAK_
= u'SUBTABLE_BREAK'¶
-
error¶
-
class
fontTools.feaLib.parser.
Parser
(featurefile, glyphNames=(), followIncludes=True, **kwargs)[source]¶ -
CV_FEATURE_TAGS
= set([u'cv01', u'cv02', u'cv03', u'cv04', u'cv05', u'cv06', u'cv07', u'cv08', u'cv09', u'cv10', u'cv11', u'cv12', u'cv13', u'cv14', u'cv15', u'cv16', u'cv17', u'cv18', u'cv19', u'cv20', u'cv21', u'cv22', u'cv23', u'cv24', u'cv25', u'cv26', u'cv27', u'cv28', u'cv29', u'cv30', u'cv31', u'cv32', u'cv33', u'cv34', u'cv35', u'cv36', u'cv37', u'cv38', u'cv39', u'cv40', u'cv41', u'cv42', u'cv43', u'cv44', u'cv45', u'cv46', u'cv47', u'cv48', u'cv49', u'cv50', u'cv51', u'cv52', u'cv53', u'cv54', u'cv55', u'cv56', u'cv57', u'cv58', u'cv59', u'cv60', u'cv61', u'cv62', u'cv63', u'cv64', u'cv65', u'cv66', u'cv67', u'cv68', u'cv69', u'cv70', u'cv71', u'cv72', u'cv73', u'cv74', u'cv75', u'cv76', u'cv77', u'cv78', u'cv79', u'cv80', u'cv81', u'cv82', u'cv83', u'cv84', u'cv85', u'cv86', u'cv87', u'cv88', u'cv89', u'cv90', u'cv91', u'cv92', u'cv93', u'cv94', u'cv95', u'cv96', u'cv97', u'cv98', u'cv99'])¶
-
SS_FEATURE_TAGS
= set([u'ss01', u'ss02', u'ss03', u'ss04', u'ss05', u'ss06', u'ss07', u'ss08', u'ss09', u'ss10', u'ss11', u'ss12', u'ss13', u'ss14', u'ss15', u'ss16', u'ss17', u'ss18', u'ss19', u'ss20'])¶
-
ast
= <module 'fontTools.feaLib.ast' from '/tmp/B.4_epm6jt/BUILD/fonttools-3.44.0/build-2/lib/fontTools/feaLib/ast.py'>¶
-
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
= u'ANONYMOUS_BLOCK'¶
-
CHAR_DIGIT_
= u'0123456789'¶
-
CHAR_HEXDIGIT_
= u'0123456789ABCDEFabcdef'¶
-
CHAR_LETTER_
= u'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'¶
-
CHAR_NAME_CONTINUATION_
= u'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.+*:^~!/-'¶
-
CHAR_NAME_START_
= u'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_+*:.^~!\\'¶
-
CHAR_NEWLINE_
= u'\r\n'¶
-
CHAR_SYMBOL_
= u",;:-+'{}[]<>()="¶
-
CHAR_WHITESPACE_
= u' \t'¶
-
CID
= u'CID'¶
-
COMMENT
= u'COMMENT'¶
-
FILENAME
= u'FILENAME'¶
-
FLOAT
= u'FLOAT'¶
-
GLYPHCLASS
= u'GLYPHCLASS'¶
-
MODE_FILENAME_
= u'FILENAME'¶
-
MODE_NORMAL_
= u'NORMAL'¶
-
NAME
= u'NAME'¶
-
NEWLINE
= u'NEWLINE'¶
-
NUMBER
= u'NUMBER'¶
-
RE_GLYPHCLASS
= <_sre.SRE_Pattern object>¶
-
STRING
= u'STRING'¶
-
SYMBOL
= u'SYMBOL'¶
-
parser¶
-
class
fontTools.feaLib.parser.
Parser
(featurefile, glyphNames=(), followIncludes=True, **kwargs)[source] -
CV_FEATURE_TAGS
= set([u'cv01', u'cv02', u'cv03', u'cv04', u'cv05', u'cv06', u'cv07', u'cv08', u'cv09', u'cv10', u'cv11', u'cv12', u'cv13', u'cv14', u'cv15', u'cv16', u'cv17', u'cv18', u'cv19', u'cv20', u'cv21', u'cv22', u'cv23', u'cv24', u'cv25', u'cv26', u'cv27', u'cv28', u'cv29', u'cv30', u'cv31', u'cv32', u'cv33', u'cv34', u'cv35', u'cv36', u'cv37', u'cv38', u'cv39', u'cv40', u'cv41', u'cv42', u'cv43', u'cv44', u'cv45', u'cv46', u'cv47', u'cv48', u'cv49', u'cv50', u'cv51', u'cv52', u'cv53', u'cv54', u'cv55', u'cv56', u'cv57', u'cv58', u'cv59', u'cv60', u'cv61', u'cv62', u'cv63', u'cv64', u'cv65', u'cv66', u'cv67', u'cv68', u'cv69', u'cv70', u'cv71', u'cv72', u'cv73', u'cv74', u'cv75', u'cv76', u'cv77', u'cv78', u'cv79', u'cv80', u'cv81', u'cv82', u'cv83', u'cv84', u'cv85', u'cv86', u'cv87', u'cv88', u'cv89', u'cv90', u'cv91', u'cv92', u'cv93', u'cv94', u'cv95', u'cv96', u'cv97', u'cv98', u'cv99'])
-
SS_FEATURE_TAGS
= set([u'ss01', u'ss02', u'ss03', u'ss04', u'ss05', u'ss06', u'ss07', u'ss08', u'ss09', u'ss10', u'ss11', u'ss12', u'ss13', u'ss14', u'ss15', u'ss16', u'ss17', u'ss18', u'ss19', u'ss20'])
-
advance_lexer_
(comments=False)[source]
-
ast
= <module 'fontTools.feaLib.ast' from '/tmp/B.4_epm6jt/BUILD/fonttools-3.44.0/build-2/lib/fontTools/feaLib/ast.py'>
-
expect_cid_
()[source]
-
expect_class_name_
()[source]
-
expect_decimal_or_hexadecimal_
()[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]
-