I had broken this in e06166b83aa82582dab2e011520b1a77f72aa9f9.
Fix that, and other issues. Since I made that last commit, it has
become clear that SingleSubst works by adding delta and then doing
module 65536.
HarfBuzz was updated for this in 2011:
commit 52ebdff49d13f239efc886de935d47be9860f6e5
Author: Behdad Esfahbod <behdad@behdad.org>
Date: Tue Sep 27 12:38:16 2011 -0400
Fix GSUB lookuptype 1 subtype 1 delta wrapping
After this change, round-tripping through TTX shrinks the size of all
our test fonts. Specifically, Skia.ttf shrinks from 478K to 473K,
JamRegular.ttf from 113K to 107K, and BuffaloGalRegular from 67K to 61K.
This make the code easier to understand, especially since there
is a diffence between numPointsInGlyph, numPointsInRun and
numPointsInData.
Also, we now pass numPointsInGlyph to compilePoints() to later
enable an optimization where numPointsInData == numPointsInGlyph.
However, this change does not yet make that optimization.
Before this change, the compilePoints() routine would wrongly clear
the most-significant bit of the lower byte in its binary output.
An example glyph affected by this bug was “perthousand.oldstyle” in
the version of Skia.ttf that Apple ships with MacOS X Yosemite 10.10.3.
Although the broken code path was exercised in the unit tests, the
length of the test input just happened to have the affected bit clear,
which is why this bug did not get caught by the previous test cases.
After this change, MacOS Yosemite 10.3.3 renders the Oslash glyph
of Skia.ttf with the exact same outline before and after round-tripping
the font through TTX. Before this change, the outlines were slightly
different after round-tripping through TTX.
In my initial reading of the “gvar” specification, I had assumed
that (0,0) entries had no significance. However, that is not
how the current MacOS implementation interprets it.
Before this change, a rounding issue in fixedToFloat() would sometimes
change 'gvar' coordinate values when round-tripping Skia.ttf through TTX.
This change works around https://github.com/behdad/fonttools/issues/286.
When compiling the set of shared coordinates, walk over glyphs in
self.variations instead of retrieving them in glyph order.
This addresses a code review comment:
0f86c1c0d3 (commitcomment-11375190)
In Python 3.2, the unittest framework fails to recognize
that (1, range(65535)) is the same as (1, range(65535)).
In any othe Python version from 2.6 to 3.4, this works fine.
In Pyton 3, range() is implemented like xrange() in Python 2,
and there is no xrange() anymore. The savings from xrange() are
too small for us to really bother, so we choose to live inefficiently
on Python 2.
With this work-around, all of {Skia, BuffaloGalRegular, JamRegular}.ttf
can be round-tripped through TTX, and the resulting TrueType font
can be displayed by MacOS X 10.9.5 including glyph variations.
In the Apple Skia font, about 5% of all tuples are redundant
because all their delta offsets are (0, 0); these tuples can
be omitted without any visual loss. But in the BuffaloGalRegular
and JamRegular fonts, there are no such redundant tuples.