52 Commits

Author SHA1 Message Date
Miguel Sousa
a7aef47695 fix "indentation contains mixed spaces and tabs" errors reported by Landscape 2015-08-09 00:33:50 -07:00
Sascha Brawer
53e7db624a [GX] Make it easier to construct ‘fvar’ tables from code
In the previous table-driven implementation, client code had to
know the internals of the ‘fvar’ structure for correctly adding
variation axes to a font. In the new implementation, clients
do not have to futz around with binary offsets (which makes it
more likely that tools build correct fonts).
2015-06-24 15:05:03 +02:00
Behdad Esfahbod
37e6e6a380 Use dict comprehension now that we don't support Python 2.6 2015-06-11 17:05:15 -07:00
Sascha Brawer
7f6d2af45a [GX] Optimize ‘gvar’ tables for tuples affecting all points in a glyph
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.
2015-06-10 11:19:06 +02:00
Sascha Brawer
4bbc1f7e83 [GX] In ‘gvar’ code, rename numPoints to numPointsInGlyph
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.
2015-06-10 10:54:08 +02:00
Sascha Brawer
f121b070f7 [GX] Emit correct number of points for long ‘gvar’ tuples
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.
2015-06-10 09:46:18 +02:00
Sascha Brawer
1426431c2f [GX] Minor: Removed unneeded variable in “gvar” handling code 2015-06-09 15:17:58 +02:00
Sascha Brawer
1d211ff058 [GX] Removed unused function argument in ‘gvar’ handling code 2015-06-09 15:08:01 +02:00
Sascha Brawer
e39c2957de [GX] Fix some minor lint warnings by landscape.io 2015-06-09 14:04:33 +02:00
Sascha Brawer
624b2b7529 [GX] In ‘gvar’ tuples, treat (0,0) different from unspecified entries
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.
2015-06-09 12:41:40 +02:00
Sascha Brawer
64d8411c1c Remove work-around for https://github.com/behdad/fonttools/issues/286 2015-06-08 23:03:17 +02:00
Sascha Brawer
cd8af14991 [GX] Leave 'gvar' coordinates unchanged when round-tripping through TTX
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.
2015-06-08 23:00:03 +02:00
Sascha Brawer
9dd0a7e4cd [GX] Replace range(len(...)) by enumerate(...)
This addresses 7271b779f3 (commitcomment-11374941)
2015-06-08 23:00:03 +02:00
Sascha Brawer
5ba59b3f4b [gvar] Take glyphs from gvar.variations
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)
2015-06-08 23:00:03 +02:00
Sascha Brawer
1447730438 Fix most pylint warnings for 'gvar' table 2015-06-08 23:00:03 +02:00
Sascha Brawer
513458f558 [GX] Test round-trip decompile/compile for glyph variations
Also, implement an __eq__ method on GlyphVariation so we can verify
whether the result of round-tripping actually equals the original input.
2015-06-08 23:00:02 +02:00
Sascha Brawer
54866e9294 Minor changes for Python 3 2015-06-08 23:00:02 +02:00
Sascha Brawer
6d5049cb57 Minor changes towards supporting python3. 2015-06-08 23:00:02 +02:00
Sascha Brawer
e4377af3fd Replace xrange() by range(), for python3
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.
2015-06-08 23:00:02 +02:00
Sascha Brawer
9bb1ca02ba [GX] Remove obsolete, unused helper method 2015-06-08 23:00:01 +02:00
Sascha Brawer
7d0f22e1e3 [GX] Temporarily disable code path for emitting shared points in 'gvar' tables
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.
2015-06-08 23:00:01 +02:00
Sascha Brawer
b309a36157 [GX] Improve tests for compiling 'gvar' tables 2015-06-08 23:00:01 +02:00
Sascha Brawer
d5005c7f3e [GX] Compile 'gvar' tables 2015-06-08 23:00:01 +02:00
Sascha Brawer
b85ff8ed31 [GX] Compile delta offsets for 'gvar' table to compact encoding 2015-06-08 23:00:01 +02:00
Sascha Brawer
94bf26eace Minor 2015-06-08 23:00:00 +02:00
Sascha Brawer
79e704807d [GX] Add comment on when to use shared versus private point lists for 'gvar' tuples 2015-06-08 23:00:00 +02:00
Sascha Brawer
970c37e395 [GX] Compile sets of packed point numbers for 'gvar' table
Work in progress. Prints out various debug info that will be removed
in the final version.
2015-06-08 23:00:00 +02:00
Sascha Brawer
6976d8ed33 [GX] Omit 'gvar' tuples whose deltas are all zero
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.
2015-06-08 23:00:00 +02:00
Sascha Brawer
303caee946 [GX] Rename decompileTuples_() to decompileGlyph_i()
For symmetry with compileGlyph_(), and because the name carries more meaning.
2015-06-08 23:00:00 +02:00
Sascha Brawer
936d079428 [GX] Fix default coordinate values for non-intermeditate 'gvar' tuples 2015-06-08 22:59:59 +02:00
Sascha Brawer
50a2ada262 [GX] Test compileGlyph() for 'gvar' table without actual variations 2015-06-08 22:59:59 +02:00
Sascha Brawer
86ecd4dac0 [GX] Build shared coordinate table when compiling 'gvar' 2015-06-08 22:59:59 +02:00
Sascha Brawer
21098228f0 [GX] Resurrect 'gvar' table from XML 2015-06-08 22:59:59 +02:00
Sascha Brawer
908bc15b74 [GX] Move decompilePoints() and decompileDeltas() into class GlyphVariation 2015-06-08 22:59:59 +02:00
Sascha Brawer
3f715e433e [GX] Move helper methods for (de)compiling GlyphVariation into class GlyphVariation
Specifically, compileCoords(), decompileCoords(), compileCoord(), decompileCoord(),
and getTupleSize().
2015-06-08 22:59:59 +02:00
Sascha Brawer
19863123d6 [GX] Add methods compileCoord() and compileCoords() 2015-06-08 22:59:58 +02:00
Sascha Brawer
c7650e5cb1 [GX] In XML for 'gvar' table, rename glyphVariation to glyphVariations
It is a list of variations, not a single variation.
2015-06-08 22:59:58 +02:00
Sascha Brawer
a82affb34c [GX] Move XML generation for GlyphVariations into separate method 2015-06-08 22:59:58 +02:00
Sascha Brawer
e0bd569a73 [GX] Align signature of decompileCoord() with that of similar methods 2015-06-08 22:59:58 +02:00
Sascha Brawer
5352ceb824 [GX] Handle intermediate coordinates in 'gvar' tuples 2015-06-08 22:59:58 +02:00
Sascha Brawer
343539d569 [GX] Write 'gvar' coordinates to XML 2015-06-08 22:59:58 +02:00
Sascha Brawer
50f3ca52da [GX] Handle embedded coordinates of 'gvar' tuples 2015-06-08 22:59:57 +02:00
Sascha Brawer
ea071c3025 [GX] Decompile non-embedded 'gvar' tuple coordinates 2015-06-08 22:59:57 +02:00
Sascha Brawer
39622ed66d [GX] Parse 'gvar' tuples and write them as XML 2015-06-08 22:59:57 +02:00
Sascha Brawer
5f317b2ed4 [GX] Decode packed point numbers 2015-06-08 22:59:57 +02:00
Sascha Brawer
1f650d7f72 Minor docfix 2015-06-08 22:59:57 +02:00
Sascha Brawer
1d90b77d2e Parse tuple header in 'gvar' table 2015-06-08 22:59:57 +02:00
Sascha Brawer
3b32f25ebd Use xrange() instead of range() 2015-06-08 22:59:56 +02:00
Sascha Brawer
9d7102fdfe [GX] Implement decoding of packed deltas 2015-06-08 22:59:56 +02:00
Sascha Brawer
37e9e04f0b Avoid string copies when parsing 'gvar' table 2015-06-08 22:59:56 +02:00