`script_code` does the reverse of `script_name`: it takes a long
script name and returns a 4-letter script code.
Both `script_name` and `script_code` raise KeyError by default,
but can optionally return a default value instead.
As Martin Hosken reported in https://github.com/fonttools/fonttools/pull/1096,
feaLib currently incorrectly handles the case where a marked input
glyph sequence in a contextual chaining sub/pos rule is split into
multiple runs, rather than being a single continuous run of ' marked
glyphs.
The consensus there was to raise a syntax error like makeotf instead of
second-guessing and silently fixing it like fontforge does.
The new `fontTools.unicodedata` module re-exports all the public
functions from the built-in `unicodedata` module, and also adds
additional functions.
The `script` function takes a unicode character and returns the
script name as defined in the UCD "Script.txt" data file.
It's implemented as a simple binary search, plus a memoizing
decorator that caches the results to avoid search the same
character more than once.
The unicodedata2 backport is imported if present, otherwise
the unicodedata built-in is used.
... instead of a glyphMap dict.
The parser does not actually need a reverse glyph order mapping as
it is not interested in knowing the glyphID from the glyph name,
but only whether a glyph is in the font or not.
This makes it easier for client code (e.g. ufo2ft feature compiler)
to use the feaLib Parser, without having to first construct and pass
it a glyphMap argument.
Right now just reflects the axes, and even that with certain limitations:
- AxisOrdering is set to the order axes are defined,
- Name-table entries are not shared with fvar.
Towards https://github.com/LettError/designSpaceDocument/issues/8
In OT kern subtable header, the format is the high byte of 'coverage'
bit mask (bits 8-15), and the low byte (bits 0-7) is the actual coverage
bits.
In AAT kern, it's the opposite: the coverage flags are the high byte,
whereas the subtable format is the low byte.
Also adjusted the test data, and set coverage to 1 for OT kern subtable
(which means the usual horizontal kerning).
- When compiling kern subtables for version=1.0 kern tables (AAT)
the subtable header was written incorrectly: there is no version,
the length is a uint32 and there's an additional uint16 for
tupleIndex
- Use the 'coverage' low byte to select subtable "format", instead
of the 'version' field, only present in OT kern subtable header.
The getkern method was failing with AttributeError on 'unknown'
subtable formats, as their class only has 'format' instead of
'version' attribute. The 'version' attribute is renamed to
'format' also to avoid confusion, but the old one is kept for
backward compatiblity. In the only implemeted subtable class,
'format' becomes a class attribute rather than instance's
(it must always be 0).
- KernTable_format_0 now takes an 'apple=False' argument, used to
know the different headers and whether to read/write tupleIndex.
- minor pep8 whitespace and indentation fixes
- A new 'tupleIndex' attribute is written out to TTX for apple
kern subtables. Old ttx files which lack that attribute will
still be read (with a warning) and will default to tupleIndex=0
when recompiled or dumped with current fonttools.
Fixes#1089
This also fixes fonttools/fonttools/issues/1030.
Although the roundtrip is generally possible when a VariationStore is built from source font data using the Superpolator model, it is possible to build region definitions that do not follow this model. Behdad cited the Skia "Q" example, where the tail of the Q is affected by two regions defined as:
min=0 peak=0.5 max=0.51 delta=+10
min=0.49 peak=0.5 max=0.51 delta=-10
Beyond composing ligatures, AAT finite-state transducers can also
execute insertion actions without rewriting existing glyphs. The
corresponding actions have almost the same structure as ligature
actions, so we can share a lot of the plumbing within fonttools.
This renaming is in preparation of a larger change to support `morx`
ables with insertions.