* [varLib.models] Add test for modeling rounding error
Tests https://github.com/fonttools/fonttools/pull/2214
If you flip demo to True, it does a slower test and demos the new error as well
as the error the old code was producing (ie. rounding deltas post-modeling).
Indeed, the new error is always capped by 0.5 as expected, whereas the old one
was unbounded. Here's the worst-case error of the bad code:
...
240 0.42 4.8
...
240 is just the line number. 0.42 is new error. 4.8 is old error.
* turn test_modeling_error into a parametrized pytest test
Like the other test methods in the same module, all those whose name starts with 'test_' are automatically discovered and run by pytest which is our default test runner. So there is no need to call the test method itself in the top-level module scope. One simply runs the test via pytest. To execute this specific test method one can do 'pytest Tests/varLib/models_test.py::test_modeling_error'.
* use pytest markers to mark specific test as 'slow'
So that one can optionally deselect tests marked with specific marker by passing -m option (e.g. to deselect 'slow' tests, pytest -m 'not slow' ...).
https://docs.pytest.org/en/stable/mark.html#registering-markshttps://docs.pytest.org/en/stable/example/parametrize.html#set-marks-or-test-id-for-individual-parametrized-test
* [varLib/models_test] Comment out non-test code
Co-authored-by: Cosimo Lupo <clupo@google.com>
In the upcoming draft of COLR spec, PaintSweepGradient's startAngle/endAngle are encoded with a +1.0 bias to allow for representation of a full +360° positive angle. Normal F2Dot14-fraction-of-half-circle angles can only represent angles between -360 <= angle < +360
This is a breaking change and will need to be coordinated with rendering implementations (at least FreeType/Skia).
There is no longer a requirement that all the masters have exactly the same base color glyphs as the default masters. Similarly, it's no longer required that all masters' LayerLists have the same total count of layers. It is sufficient that, for a base color glyph in the default master, a non-default master may (or may not) contain one with the same name and same effective number of layers (which in turn can be laid out differently in the respective LayerLists).
This provides greater flexibility when working with variable font project with sparse glyph sets.
previously we only reused the VarIndexBase of a previously seen variable table when the current's varIdxes were _fully_ equal to one of the previous; now we also try to find a match anywhere in the accummulated list of self.varIdxes, including a partial match at the tail of the list.
When multiple variable tables refer to the same delta-sets they can now share the same VarIndexBase so the resulting DeltaSetIndexMap is a bit smaller.
For simplicity, we only reuse VarIndexBase when variable tables fully share (ie. same, and same number of) varIdxes; potentially we could reuse subsets of varIdxes (e.g. a VarColoStop.Alpha has a +0.5 delta, and later on elsewhere a PaintVarSolid.Alpha has a similar +0.5 delta; the latter could have a VarIndexBase that reuses an existing DeltaSetIndexMap entry for the former), but for now this I think is good enough.
This does two things:
Fixes forced-set computation, which was wrong in multiple ways.
Debugged it. Is solid now... Famous last words.
Speeds up DP time by limiting DP lookback length. For Noto Sans,
IUP time drops from 23s down to 9s, with only a slight size increase
in the final font. This basically turns the algorithm from O(n^3) into
O(n).
this currently raises AttributeError in MutatorMerger.merge for ValueRecord table, because the latter assumes that whenever one of the Device tables are present the respective non-device values are also present, but they may be omitted (and it should default to 0 when missing)