21 Commits

Author SHA1 Message Date
Cosimo Lupo
f220d36df1
instancer: merge TupleVariations left with same axes after pinning
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.
2019-04-04 15:11:23 +01:00
Cosimo Lupo
5f083bdf2e
refactor instantiateItemVariationStore for better test-ability
The function now takes a VarStore instance, the fvar axes and a partial
location, and returns an array of delta-sets to be applied to the
default instance.

The algorithm is now more similar to the one used for instantiating the
tuple variation store.

Tests are coming soon.
2019-03-28 17:52:59 +00:00
Cosimo Lupo
3699f5b08c
call VarData.calculateNumShorts after scaling or dropping deltas 2019-03-26 19:02:51 +00:00
Cosimo Lupo
e6033a14da
instancer: drop region if axis scalar is 0
update VarData.VarRegionCount

also set StartCoord and EndCoord to 0 (same end result as only setting PeakCoord
to 0, but this produces less noise when inspeciting the generated XML dump)
2019-03-26 18:44:50 +00:00
Cosimo Lupo
7dd0390579
fix rounding deltas after applying scalars to ItemVarStore
ok, really time to add some better tests.
2019-03-26 16:30:57 +00:00
Cosimo Lupo
403782d5f2
fixup previous commit
even if none of the referenced regions in this VarData are dropped we may still
have to apply the scalars...
2019-03-26 16:21:18 +00:00
Cosimo Lupo
ef14ee9aac
keep VarData unchanged if none of its referenced regions are being dropped 2019-03-26 16:07:46 +00:00
Cosimo Lupo
24569eec9d
drop VarData if all regions referenced by it are removed 2019-03-26 15:31:20 +00:00
Cosimo Lupo
0b43253369
refactor and simplify instantiateItemVariationStore
we can reuse the prune_regions method defined in varStore.py to update
the VarRegionList.

also update the counts at the end (will be done automatically on compile anyway).
2019-03-26 13:48:54 +00:00
Nyshadh Reddy Rachamallu
38fc6b6611
Bug fix for ItemVariationStore instantiation. 2019-03-26 10:18:15 +00:00
Cosimo Lupo
c9a00f4ad0
minor refactoring of instantiateFeatureVariations to make it easier to test 2019-03-26 10:14:16 +00:00
Cosimo Lupo
f3aa8d5c90
fix instantiateFeatureVarationStore, was renamed instantiateFeatureVariations 2019-03-26 09:57:52 +00:00
Nyshadh Reddy Rachamallu
1585017345 Add FeatureVariation instantiation (for GSUB, GPOS) 2019-03-25 16:14:57 -04:00
Cosimo Lupo
dbad6da5c9
instancer: enumerate fvar axis indices only once then look them up
fvar axis tags are unique, we can compute the mapping from tag to index
once and reuse when we need them index from the tag.
2019-03-25 13:56:38 +00:00
Cosimo Lupo
2b746d6e50
instancer: unpack axis (start, peak, end) tuple instead of indexing at PEAK_COORD_INDEX
Makes it more readable
2019-03-25 13:41:41 +00:00
Cosimo Lupo
846e7b3ec4
instancer: round MVAR deltas at the end
and don't use enumerate() when iterating over region axes, as get_support() method returns a dict
2019-03-25 13:15:50 +00:00
Cosimo Lupo
bb667f6841 rename applyCvtDeltas to setCvarDeltas
for consistency with set{Gvar,Mvar}Deltas
2019-03-22 17:32:05 +00:00
Cosimo Lupo
fa57f7e931 instancer: only round deltas if we did scale them 2019-03-22 17:30:30 +00:00
Cosimo Lupo
29c7a11f77 minor: fix 'NameError: parser not defined' 2019-03-22 15:28:03 +00:00
Cosimo Lupo
62c98b451a instancer: share same instantiateTupleVariationStore for both gvar/cvar
refactored code, hopefully simplifying things a bit.

for cvar/cvt we do the rounding only at the end after we have summed the scaled deltas
to avoid introducing unnecessary rounding errors.
2019-03-22 14:15:53 +00:00
Cosimo Lupo
6281f87cb6 rename partialInstancer.py to instancer.py 2019-03-21 15:30:48 +00:00