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
Fixes https://github.com/behdad/fonttools/issues/314
Previously the warning message was wrong (probably a regression)
as it was reporting the the length of all kern data as "excess".
Fixing that, I see 4 bytes excess in Calibri. Up to 4 is alright,
since many compilers add padding and wrongly add 4 instead of 0
sometimes.
A couple of modules were relying on the fact that the 'sys' module was being implicitly imported by 'from py23 import *'.
The 'py23.__all__' does not include 'sys'. I think it's better to always import 'sys' explicitly when needed.
Was "broken" in the performance work in commits
8724513a67f954eac56eeb77ced12e27d7c02b6b and
1d93f9099de4987c5c7d7e49a23f4c46a45dfab2.
Use slow method if exception raised.
The changes should move to TTFont layer itself. I'll move them
in a separate commit.