1397 Commits

Author SHA1 Message Date
Behdad Esfahbod
a0686e8d2e [visitor] Add register_attr(s) example 2022-08-15 12:37:38 -06:00
Behdad Esfahbod
41e6f60011
Merge pull request #2738 from fonttools/glyphset
TTVarGlyphset
2022-08-15 11:07:41 -06:00
Behdad Esfahbod
dc99ab6b3f [ttGlyphSet] Address review comments 2022-08-15 11:06:51 -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
Cosimo Lupo
87e86cb5fb
Merge pull request #2731 from fonttools/pyup-scheduled-update-2022-08-08
Scheduled weekly dependency update for week 32
2022-08-15 11:33:37 +01:00
Cosimo Lupo
0f33634a9e subset_test: fix mock test with uharfbuzz>=0.30 new 'repack_with_tag' method 2022-08-15 12:10:13 +02:00
Behdad Esfahbod
e31b214089 [visitor_test] Make it into the start of a font rescaler 2022-08-14 14:43:28 -06: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
Behdad Esfahbod
26ae03f58f [ttGlyphSet] Add tests 2022-08-14 12:52:49 -06:00
Behdad Esfahbod
cdc5307d1b
[merge] Use '.' instead of '#' in duplicate glyph names (#2742)
Fixes https://github.com/fonttools/fonttools/issues/1950
2022-08-14 12:49:35 -06:00
Behdad Esfahbod
8fe672c6a2 Add misc.visitor.py
Fixes https://github.com/fonttools/fonttools/issues/1959
2022-07-31 12:27:09 -06:00
Cosimo Lupo
d5dd4d297f subset_test: catch ImportError instead of ModuleNotFoundError 2022-07-18 12:17:35 +02:00
Jany Belluz
b5f9499d2d [designspaceLib] Don't make up bad PS names when no STAT data
See GitHub issue: https://github.com/googlefonts/ufo2ft/issues/630
2022-07-07 11:56:51 +01:00
Cosimo Lupo
b8333d9ade instancer_test: revert expected result to before, to match eab9aa5 2022-07-06 16:50:22 +01:00
Cosimo Lupo
14f88fb781 Fix cu2quPen_test.py for python 3.11
Credits to pnamade from https://github.com/fonttools/fonttools/pull/2655
2022-07-06 11:16:02 +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
2a07518b70
Merge pull request #2660 from fonttools/variable-colr
[varLib] add support for building variable COLR from set of master COLRv1 tables
2022-07-06 10:55:50 +01:00
Cosimo Lupo
46e780ffa2
Merge pull request #2668 from googlefonts/hb_repack
Update how table packing falls back to fontTools from harfbuzz.
2022-07-06 10:49:39 +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
a3f402e036 move build_n_ary_tree to misc/treeTools.py module
so I can import from varLib.merger as well
2022-07-04 23:08:14 +01:00
Cosimo Lupo
3b0769b519 colorLib: let clipBoxes contain more glyphs than colorGlyphs, helps with sparse variable builds 2022-07-04 18:44:54 +01:00
David Corbett
8ec37c4bb3 [feaLib] Let the parser set nameIDs 1 through 6 2022-07-02 15:23:03 -04: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
Garret Rieger
4acad94b93 Update harfbuzz repack test failure message expectation. 2022-06-27 18:13:52 +00: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
97958a95e1
Merge pull request #2662 from fonttools/varstore-empty
[varLib.varStore] Support NO_VARIATION_INDEX
2022-06-23 12:02:00 -06: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
Simon Cozens
d224e1f73d
[feaLib] show all missing glyphs at once (#2665) 2022-06-23 15:04:59 +01:00
Cosimo Lupo
bc8f1cfac4 varLib.errors: more informative message with unsupported/inconsistent formats 2022-06-21 17:27:12 +01:00
Cosimo Lupo
676a66fad3 otTables: make DeltaSetIndexMap TTX dump less verbose by omitting no-op entries
though we still emit the empty <Map index=.../> elements; they help identify chunks of delta-set indices, and define the length of the array upon loading from XML
2022-06-21 17:27:11 +01:00
Cosimo Lupo
c612b2637f colorLib.unbuilder: ensure unbuildColrV1 flattens nested PaintColrLayers 2022-06-21 17:27:11 +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
Cosimo Lupo
119b7732cc SVG: strip timestamp to make compressed gzip reproducible
we tell GzipFile to write the MTIME field to zero so that the compressed output is reproducible and doesn't change depending on when the data is compressed.
2022-06-09 16:29:29 +01:00
Cosimo Lupo
8673073a87 S_V_G__test: test compiling/decompiling compressed doc 2022-06-09 15:27:57 +01:00
Nikolaus Waxweiler
42e4d66184
Merge pull request #2609 from fonttools/ds5-add-some-polish
[designspaceLib] Add some polish to the v5 paths
2022-05-04 16:13:03 +01:00
Cosimo Lupo
b488d10768
Merge pull request #2611 from tshinnic/svglib_parser_real_number_format
Handle one more valid real number format in svgLib parse_path()
2022-05-04 08:27:24 +01:00
Cosimo Lupo
a09e80b1b1
Merge pull request #2596 from tshinnic/path_arc_rx_ry_nonnegative
Protect SVG path parsing from negative rx ry on arc commands
2022-05-04 08:14:15 +01:00
Thomas Shinnick
5abfef15e1 Handle one more valid real number format in svgLib parse_path()
Using svg.draw(pen) and parse_path() from svgLib threw exception
     ValueError: could not convert string to float: 'a'
on a SVG <path> string generated by Inkscape. Altering the path
string might object to other string bits like 'Z' or 'v', or
give even stranger exceptions.

Finally tracked it down to the path containing particular valid
numbers like "-4e-5" or "1e-4". Changing these to "-4.0e-5" or
"1.0e-4" would stop the exceptions. The parse_path() was not
accepting valid SVG real numbers.

The specification for real number formats is a bit of a mess in
CSS land right now, but the reassuringly concrete spec is:
    https://www.w3.org/TR/css-syntax-3/#number-token-diagram
which allows a real number having an exponent but without having
a fractional part, such as the number "1e3".

This change updates an RE to make fractional parts optional,
and adds a test for this valid SVG number format.
2022-05-03 17:48:14 -05:00