Fixes#1650
A regression was introduced with 3.43.0 when doing pyftsubset --flavor=woff2
and the input font is WOFF 1.0, thus it has a non-None flavorData already
but doesn't define the transformTables attribute.
- changed getCoordWidth method to use all if-stmt, ordered by ret value (0, 1, 2).
- added more info to TypeError message in getCoordWidth method.
- in round/scaleDeltas, chained if statements in one line to avoid writing the loop twice.
Also, the TTFont.getGlyphOrder() automatically makes up a dummy
glyph order from the maxp.numGlyphs, we simply need to ensure
'maxp' is decompiled before 'glyf'.
When transforming glyf, the glyf.glyphOrder is guaranteed to
be present (as the glyf table has been already decompiled), so
we don't need to deal with it being missing or incorrect
(hence removed spurious tests).
varLib._GetCoordinates (which this method is copied from) did not return such data either.
The problem with also including component flags in the returned controls
tuple is that different masters may happen to have different component
flags (e.g. if one master has USE_MY_METRICS, another doesn't).
glyph.recalcBounds is called unconditionally a few lines below within the same
setCoordinates method, just after setting the new glyph's coordinates.
We don't need to call recalcBounds twice.
Only empty glyphs with numberOfContours == 0 may not have xMin set.
recalcBounds ensure it's set to 0 for those.
The instantiateTupleVariationStore function now groups TupleVariation
tables that have the same axes 'tents', then merges them into a single
TupleVariation by summing their deltas. The rounding to integer happens
after summing the scaled deltas as floats, to reduce off-by-one errors.
To be able to sum gvar TupleVariation, it needs to calculate the inferred
deltas so it now takes two optional lists (origCoords and endPts) that
are passed on to iup_delta function. These only make sense for gvar
type of TupleVariation, of course, and are unused for cvar tuples.
It also run iup_delta_optimize on the gvar deltas that are left after
partial instancing and whose inferred deltas had to be interpolated.
This can be disabled with --no-optimize CLI option.
Also added calcInferredDeltas and optimize methods to TupleVariation
class, which use functions from varLib.iup module, plus tests
that exercise them.
Unlike simple glyphs, which always have 'program' attribute (even when empty, with no instructions)
in composite glyphs, it's the presence of 'program' attribute that determines whether
the optional WE_HAVE_INSTRUCTIONS component flag is set or not.
Thus, the trim method (with remove_hinting=True) should delete the attribute for
composite glyphs.
Fixes https://github.com/fonttools/fonttools/issues/1550