309 Commits

Author SHA1 Message Date
Behdad Esfahbod
32904d43bb [models_test] Add tests from Just 2022-08-16 12:46:44 -06:00
Behdad Esfahbod
3325b47606
Merge pull request #2717 from fonttools/varLib-narrow
[varLib.models] Generate narrower tents
2022-08-16 12:46:22 -06:00
Behdad Esfahbod
03d264756b
Test var model error (#2217)
* [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-marks
https://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>
2022-08-15 10:30:45 -06:00
Cosimo Lupo
1dffbae240 support proposed PaintSweepGradient's angles with +1.0 (180°) bias
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).
2022-08-15 12:52:28 +02:00
Behdad Esfahbod
688939394b [varLib.models] Generate narrower tents
Based on https://github.com/fonttools/fonttools/pull/2218
but modify the general solver instead.
2022-08-14 14:00:09 -06:00
Cosimo Lupo
b8333d9ade instancer_test: revert expected result to before, to match eab9aa5 2022-07-06 16:50:22 +01:00
Nikolaus Waxweiler
ce38db6562
Merge pull request #2673 from daltonmaag/instancer-set-bits
Set RIBBI bits when cutting instances
2022-07-06 11:01:08 +01:00
Cosimo Lupo
f1d715dbb1 Add integration test for variable COLR in varLib_test.py 2022-07-06 10:24:16 +01:00
Cosimo Lupo
ef3775a084 merger_test: add test for expandPaintColrLayers method 2022-07-06 09:59:16 +01:00
Cosimo Lupo
fd397bac32 merger_test: test with masters' layer reuse off and on to confirm output is the same 2022-07-06 09:14:17 +01:00
Cosimo Lupo
8a9f16d129 COLRVariationMerger: copy destination layers to ensure they are unique and can be modified in place 2022-07-05 17:53:39 +01:00
Nikolaus Waxweiler
16d899a2be Apply RIBBI bits to all kinds of fonts 2022-07-05 15:45:44 +01:00
Cosimo Lupo
e5029801d2 support merging COLR masters with 'sparse' glyphsets or different layer count
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.
2022-07-05 00:11:12 +01:00
Cosimo Lupo
c2887caf95 varLib/merger_test: test merging ClipBoxes 2022-06-28 18:23:06 +01:00
Cosimo Lupo
d85aa2d119 COLRVariationMerger: further optimize DeltaSetIndexMap
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.
2022-06-28 14:11:28 +01:00
Cosimo Lupo
c397764720 COLRVariationMerger: implement reuse of VarIndexBase between tables with same varIdxes
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.
2022-06-27 17:17:32 +01:00
Cosimo Lupo
2b6e813b98 varLib/merger_test: minor reorder sub-tests to follow incremental PaintFormat 2022-06-27 15:38:55 +01:00
Cosimo Lupo
f98c860ff2 Start adding Tests/varLib/merger_test.py for COLRVariationMerger 2022-06-24 18:16:28 +01:00
Cosimo Lupo
fcd2a67f52 Merge remote-tracking branch 'origin/main' into variable-colr 2022-06-24 10:16:51 +01:00
Behdad Esfahbod
5d70109645 [varStore] Comment 2022-06-23 12:01:20 -06:00
Behdad Esfahbod
e01f643a8e [varLib.varStore] Support NO_VARIATION_INDEX in optimizer & instancer
Fixes https://github.com/fonttools/fonttools/issues/2211
2022-06-23 12:01:20 -06:00
Cosimo Lupo
bc8f1cfac4 varLib.errors: more informative message with unsupported/inconsistent formats 2022-06-21 17:27:12 +01:00
Behdad Esfahbod
0d7d7d4e11 [varLib.iup] Rewrite force-set conditions & limit DP lookback length
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).
2022-06-20 17:09:36 -06:00
Cosimo Lupo
4fff281c7e varLib_test: fix expected error message 2022-06-13 12:19:38 +01:00
Nikolaus Waxweiler
9f984d93f7 Fix up tests 2022-04-29 18:13:03 +01:00
Jany Belluz
2ea5dc3496 [varLib] Add support for designspace 5 + STAT generation + tests 2022-04-14 15:05:50 +01:00
Simon Cozens
2d62a2ac9e
Disable GSUB5 optimization (#2540)
* Disable GSUB5/GPOS7 optimization

* Revert "Fixup test expectations"

This reverts commit 7db13c9872884772312727e3478fb36ed9883004.

* Revert "Rename GPOS8->GPOS7"

This reverts commit 6d4c5fe31c9199e6d3e46cd0808e7640d1610e75.

* Revert "Fix varlib test expectations - now badly named."

This reverts commit 4adea942cc73b6afe58e00278da6cb3795935970.

* Allow GSUB5, disable GPOS7

* Revert "Revert "Fixup test expectations""

This reverts commit 42993ae6917f8f6e4c31f4be123caca24d27d2da.

* Fix up expectations
2022-04-08 15:54:34 +01:00
Cosimo Lupo
7ee2c9d891 testTools: factor our method to strip variable items from ttx dumps
it was scattered here and there, so define it once and reuse everywhere needed
2022-04-05 18:34:30 +01:00
Khaled Hosny
47457b14d6
[varLib] Fix instantiating some SinglePos subtables (#2555) 2022-03-22 08:34:18 +00:00
Khaled Hosny
232b2ccbc4 Move the rest of py23 module to textTools
Change all imports to use textTools module, except the test_py23.py test
which is kept until we decide to remove the module (if ever).
2021-08-20 01:29:45 +02:00
Khaled Hosny
000bf81700 Default to "\n" for newlinestr instead of None
If newlinestr is None, os.linesep is used, bu it is the third millennium
and we don’t need or want different line endings per-platform.
2021-07-30 04:12:33 +02:00
Cosimo Lupo
dafce3ff46 instancer_test: add test with PairPos ValueRecord with XAdvDevice but no XAdvance
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)
2021-05-25 12:30:35 +01:00
justvanrossum
2636325844 font placeholder doesn't need an fvar table 2021-05-04 19:29:39 +02:00
justvanrossum
d3fd46e3f3 uncomment failing tests 2021-05-04 18:21:37 +02:00
justvanrossum
ad438931e4 adding compile/decompile step; this currently fails for the 32-bit tests (which are therefore commented out) 2021-05-04 17:08:27 +02:00
justvanrossum
267ab2baba add 32-bit master value tests 2021-05-04 16:39:20 +02:00
justvanrossum
22dda54616 use optimizer 2021-05-04 16:19:48 +02:00
justvanrossum
7de2f347c5 add tests for OnlineVarStoreBuilder/VarStoreInstancer 2021-05-04 16:12:24 +02:00
justvanrossum
a7fd202952 add 32-bit tests to test_buildVarData_optimize 2021-05-04 14:49:12 +02:00
justvanrossum
eba058d439 add 32-bit tests to test_buildVarData_no_optimize 2021-05-04 14:41:01 +02:00
Zachary Scheuren
41da60f130 Add missing dict operators to CFF2 2021-03-30 21:24:14 +09:00
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
2021-03-29 11:45:58 +02:00
Behdad Esfahbod
2a483f9856 [Tests] Fix most test expectations for AlternateSubst .Format removal 2021-03-23 18:01:32 -07:00
Behdad Esfahbod
6b2b2f4949 [Tests] Fix most test expectations for ClassDef[12] .Format removal 2021-03-23 11:43:46 -07:00
Behdad Esfahbod
9ac1f39045 [Tests] Fix most test expectations for AlternateSubst .Format removal 2021-03-23 11:43:22 -07:00
Behdad Esfahbod
b62170e86d [Tests] Fix most tests expectations for LigatureSubst .Format change 2021-03-23 11:43:15 -07:00
Behdad Esfahbod
61b06a7fe0 [Tests] Fix most tests expectations for SingleSubst .Format change 2021-03-23 11:43:03 -07:00
Behdad Esfahbod
de81aae164 [Tests] Fix more tests expectations for Coverage/ClassDef .Format change 2021-03-23 11:42:54 -07:00
Behdad Esfahbod
975f85ed72 [Tests] Fix most tests expectations for Coverage/ClassDef .Format change 2021-03-23 11:42:38 -07:00
Simon Cozens
23cb8b989b More tests 2021-03-18 21:24:13 +00:00