In format 2 and 6, AAT lookups contain a binary search header with
the number of elements in the lookup table. Before this change, the
element count would also include the special trailing end-of-table
value that is required by the font format specification. However,
the binary search header should only count the actual elements
without the trailer.
Also, in the examples from the AAT specification, the special
end-of-table entries use 0xFFFF for glyph ID keys, and zeroes
for the filler values. Before this change, we had filled the
values with 0xFF bytes.
After this change, fonttools is able to dump the `lcar` table of
the AppleChancery font to XML. However, the resulting XML cannot
be compiled back to TrueType, yet. So, something is still broken
with the implementation of AAT lookups. Need to do more testing
before the support for table `lcar` can be added to fonttools.
Before this change, the code assumed that all values of AAT lookups
get internally represented as strings, which is correct for GlyphID
values but not generally the case.
Also renaming the XML element from `Substitution` to `Lookup`
because AAT lookups have other uses beyond glyph substitutions.
Before this change, the decoder would silently remove "redundant" values
when decompiling AAT lookups. However, it is perfectly valid for a lookup
to map a glyph ID to itself, and also not all AAT lookups have glyph IDs as
their value range.
With AAT, the same lookup data structure can be used for various
types of values. In the morx table, the values are glyph IDs or
glyph classes, which both are encoded as 16-bit unsigned integers.
In other AAT tables, however, the values can be different data types
with different encodings. By passing a `valueWriter` callback and
explicit `valueSize`, we prepare for eventually templatizing
the building of AATLookups.
Also, assert that the called writer wrote the exact number of bytes
that was predicted when figuring out what format should be used for
encoding an AATLookup.
For AAT lookup format 2 (and other formats too), we need to shuffle
the data before we can estimate the encoded size. After this restructuring,
this data shuffling only needs to happen once.
Currently, this makes no difference at all. Later, we'll use this
for dispatching AAT lookup types in the same way how we already
dispatch OpenType lookup types.
Now reading XML and immediately writing it back to XML should be fully
supported and generate the same XML.
Code is a bit hacky (we don't have the reader object, so abuse font for
passing state down tree...).
Not really all... Propagated counts are still not populated.
Most of mti_tests pass again. Four failing now.
NB: In the code being removed in this commit, this line:
"setattr(self, conv.repeat, len(seq)+conv.aux)"
had the wrong sign for conv.aux. Should have been a minus.
A while back I changed code such that Lookup.LookupType is written as a
comment in XML, and ignored when compiling. The LookupType from type
of actual subtables in a lookup were used during compilation instead.
This caused the problem where an empty lookup (one with no subtables)
would lose its lookup types, among other subtle problems.
With this change we revert above behavior, but keep the benefits: if
Lookup.LookupType is different from actual lookup type of the subtables,
compilation raises an exception. Setting LookupType on Lookup object
or in XML is optional now, but written out by default in XML (instead
of as a comment).
This changes XML output for all GSUB/GPOS tables. I'm sorry for the
noise. Please update your sources.
Fixes https://github.com/fonttools/fonttools/issues/789
This does it for the simple cases, but not propagated ones.
Also, when writing to XML, if a Count or otherwise-computed value is
not set, don't write it out.
API Change:
This will change XML output for GSUB/GPOS/GDEF/MATH/BASE/JSTF/...
Scripts that set the Version for those to 1.0 or other float values
also need fixing. A warning is emitted when code or XML needs fix.