54 Commits

Author SHA1 Message Date
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
Cosimo Lupo
5558ccd3bb [colorLib.geometry] use math.isclose with relative tolerance to check circle inside-ness
Fixes rounding of radial gradient in 'SING OF THE HORNS' (medium-light skin tone) noto emoji 🤘🏼
2022-01-31 18:05:26 +00:00
Cosimo Lupo
e68a5a173c colorLib_test: check that duplicate base glyphs share share the same PaintColrLayers
this test currently fails; currently the second, third, etc. base glyphs with the same layers gets a unique PaintColrLayers with NumLayers:1 that in turn contains the shared PaintColrLayers. They should instead all share the same PaintColrLayers. Fix in the next commit
2022-01-21 19:08:22 +00:00
Cosimo Lupo
58ac5a9fd8 have ClipList and ClipBox format start at 1, not 0
b7e81fcbd6
2021-08-02 19:34:30 +02:00
Cosimo Lupo
800bf85b2f add ClipList.Format so we can bump when we finally get >16bit GIDs
https://github.com/googlefonts/colr-gradients-spec/issues/346
2021-07-29 15:35:08 +02:00
Cosimo Lupo
bee2c85f61 [colrv1] otData: define ClipList, ClipBox, etc. 2021-07-28 18:04:48 +02:00
Cosimo Lupo
29a2ebf813 omit default VarIndexBase
4294967295 (0xFFFFFFFF in decimal form) is not very memorable.
Still, using hex notation for all VarIndexBases would make the non-default values less readable (when interpreted as an index into the DeltaSetIndexMap array, decimal makes more sense).
Since 0xFFFFFFFF means 'no variation data', it makes sense to omit it from the ttx dump and write an empty <VarIndexBase/> element with no value.
We also allow to build Var tables without needing to pass "VarIndexBase": 0xFFFFFFFF in the source dict.
2021-07-23 17:27:57 +01:00
Cosimo Lupo
e5d0c00fab fix colorLib tests after adding VarIndexBase, ColorIndex removed, etc. 2021-07-23 17:27:57 +01:00
Cosimo Lupo
d0d59d2f2c Add PaintScale* and Paint{Rotate,Skew}* variants
This updates fonttools to match the latest draft COLRv1 spec at https://github.com/googlefonts/colr-gradients-spec/pull/290

Summary of changes:
- Added 8 new PaintScale* tables: with/without centers, uniform vs non-uniform
- Added *AroundCenter variants to PaintRotate and PaintSkew (default versions no longer have centerX/Y defaulting to origin)
- PaintRotate, PaintSkew and PaintComposite formats re-numbered
2021-06-28 18:38:47 +01:00
Cosimo Lupo
1cb7e36bbd COLRv1: rename otData structs to remove 'V1' to match updated draft spec
This is a breaking change (but the COLRv1 API was already marked as unstable and subject to change)

The changes in this PR are meant to match the changes from the COLRv1 draft spec at:
https://github.com/googlefonts/colr-gradients-spec/pull/302
2021-06-28 16:13:47 +01:00
Cosimo Lupo
f2df149db3 COLR: set {BaseGlyph,Layer}RecordArray to None when no colorGlyphsV0 in populateCOLRv0
Same when LayerV1List is empty. All these fields are optional in v1
2021-05-14 10:47:13 +01:00
Just van Rossum
d601951eab
[otTables] Default varIdx should be 0xFFFFFFFF (#2298)
* default value for varIdx should be 0xFFFFFFFF to indicate 'no variations'

* use lc hex notation as per feedback
2021-05-07 22:26:48 +02:00
rsheeter
7abd234929
Update tests for new formats 2021-02-15 10:42:59 +00:00
rsheeter
0353c809cd Update COLR build fns per review feedback 2021-02-12 10:02:08 -08:00
rsheeter
cf4a4087be Generic build fns 2021-02-10 09:40:37 -08:00
Cosimo Lupo
df672a7ae4
move PaintFormat enum outside of Paint class nested scope
When a TTFont is loaded with lazy=True, the otTables are only loaded upon BaseTable.__getattr__
when the requested attribute is not found in the instance __dict__.
Since the Paint.Format enum was defined at class level, every Paint instance, even when loaded
lazily, will have a 'Format' attribute and the magic decompile-on-missing-attribute will not
trigger, since the class attribute will be returned when the instance is missing one.

For this reason, and to not add further special cases, it's better to simply move this Paint.Format
enum class outside to the module level scope, and rename it PaintFormat.
2021-02-05 12:11:43 +00:00
Cosimo Lupo
a7d145f027
update tests for PaintSweepGradient 2021-02-03 19:11:44 +00:00
Cosimo Lupo
93c23eaaf7
COLRv1: define new PaintSweepGradient, amend tests with new format numbers 2021-02-03 18:21:09 +00:00
Cosimo Lupo
7516e0d95d
builder_test: add test with len(paints) > 255 2021-01-18 17:35:48 +00:00
Cosimo Lupo
9d33afe04d
COLRv1: support unlimited paints as 255-ary tree of PaintColrLayers
Fixes https://github.com/googlefonts/nanoemoji/pull/225

E.g. BASKET noto-emoji U+1F9FA contains 364 layers
2021-01-18 17:33:21 +00:00
Cosimo Lupo
b465dcff75
rename function to round_start_circle_stable_containment
as suggested in https://github.com/fonttools/fonttools/pull/2148#discussion_r557656073
2021-01-15 17:37:11 +00:00
Cosimo Lupo
4f1102ac6e
add a Circle class, handle concentrical case, explain why 2 iterations are enough 2021-01-15 16:59:17 +00:00
Cosimo Lupo
db14e6375e
COLRv1: avoid abrupt change after rounding c0 when too near c1's perimeter
Fixes https://github.com/googlefonts/picosvg/issues/158

Also see https://github.com/googlefonts/colr-gradients-spec/issues/204
2021-01-14 17:13:22 +00:00
Cosimo Lupo
538528d5a1
COLRv1: Implement PaintTranslate
https://github.com/googlefonts/colr-gradients-spec/pull/163
2020-12-15 16:58:31 +00:00
rsheeter
d888526659 Hook up paint skew and rotate 2020-12-02 21:21:19 -08:00
Cosimo Lupo
b6ef2408c5
colorLib_test: test that we accept either tuple or list for COLRv0 layer
https://github.com/googlefonts/ufo2ft/issues/426
2020-11-16 16:29:18 +00:00
rsheeter
cf2097f7c0 Update to builder per review discussion 2020-11-10 21:51:33 -08:00
rsheeter
cd39e6e246 Add a test 2020-11-06 14:59:52 -08:00
rsheeter
5c83b5be47 Don't generate a PaintColrLayers for a list of 1 2020-11-04 21:59:30 -08:00
rsheeter
f531038bf9 Start hooking up revised PaintColrLayers 2020-11-04 14:36:43 -08:00
Cosimo Lupo
e992953474
swap xy and yx fields in COLRv1 Affine2x3 struct
following the latest draft
See discussion at https://github.com/googlefonts/colr-gradients-spec/pull/85
2020-10-30 19:29:59 +00:00
Cosimo Lupo
6c752f677f
rename Paint{ColorGlyph,ColrSlice} 2020-10-27 19:15:50 +00:00
Cosimo Lupo
b654554109
add {First,Last}LayerIndex to PaintColorGlyph
as proposed in https://github.com/googlefonts/colr-gradients-spec/issues/86

The name of PaintColorGlyph may still change to PaintColorSlice, or PaintColrSlice, or PaintColorGlyphSlice, etc."
https://github.com/googlefonts/colr-gradients-spec/pull/87
2020-10-27 12:47:10 +00:00
Cosimo Lupo
8cffabfb58
builder_test: test buildPaint{ColorGlyph,Transform,Composite} 2020-10-26 18:14:13 +00:00
Cosimo Lupo
1803283baf
colorLib: use IntEnum instead of 'magic' Paint format integers
makes code more readable
2020-10-26 18:14:13 +00:00
Cosimo Lupo
a2aaf41a7e
colorLib: rename builders to match current Paint format names 2020-10-09 19:36:35 +01:00
Cosimo Lupo
fdf6a5c1fc
colorLib: update builders to latest COLRv1 draft
LayerV1Record and Affine2x2 are gone.
LayerV1List now contains a list of Paint DAGs
Added 4 new Paint formats: PaintGlyph, PaintColorGlyph, PaintTransform
and PaintComposite
2020-10-09 19:36:35 +01:00
Cosimo Lupo
ff79338607
rename radial gradient Paint.Affine attribute to Transform
as suggested by Peter Constable in
https://github.com/PeterConstable/OT_Drafts/blob/master/COLR_V1/COLRv1formats_rev3.md#paintformat3-table-conicalradial-gradient
2020-07-02 12:21:12 +01:00
Cosimo Lupo
ac0a755d20
make linear/radial gradient 'point-less', inline x0,y0,x1,y1,...
https://github.com/googlefonts/colr-gradients-spec/issues/21
2020-07-02 12:11:40 +01:00
Cosimo Lupo
dea9896421
rename COLR Color -> ColorIndex, transparency to alpha
https://github.com/googlefonts/colr-gradients-spec/issues/17
https://github.com/googlefonts/colr-gradients-spec/issues/19
2020-07-02 10:27:47 +01:00
Cosimo Lupo
4578f96e9d
colorLib_test: minor cosmetic changes 2020-07-01 18:29:26 +01:00
Cosimo Lupo
b215c000df
Rename LayerV1Array to LayerV1List, like with BaseGlyphV1List
See https://github.com/googlefonts/colr-gradients-spec/issues/14#issuecomment-652542829
2020-07-01 18:22:03 +01:00
Cosimo Lupo
5f18d9891c
rename BaseGlyphV1Array to BaseGlyphV1List
As suggested by Peter Constable in https://github.com/googlefonts/colr-gradients-spec/issues/14 and https://github.com/googlefonts/colr-gradients-spec/issues/18
2020-07-01 18:16:07 +01:00
Cosimo Lupo
971bcbff6f
colorLib: allow color stops to be built from list of dicts as well as tuples 2020-03-12 16:03:11 +00:00
Cosimo Lupo
5a8830ebc9
colorLib_test: add test for buildCORL with automatic or explicit 'version' 2020-03-11 19:01:25 +00:00
Cosimo Lupo
63e2be484e
colorLib: refactor _splitSolidAndGradientGlyphs and add test 2020-03-11 14:22:58 +00:00
Cosimo Lupo
5629d5d8d9
colorLib: allow to build Paint, ColorLine, Color from dict 2020-03-11 13:27:59 +00:00
Cosimo Lupo
0149f40588
colorLib_test: add tests for buildLayerV1Array, buildBaseGlyphV1Array 2020-03-10 15:34:53 +00:00
Cosimo Lupo
44d729ad3c
colorLib: in buildColorStop accept color tuple as parameter
and use Sequence instead of List for input params type hints
2020-03-10 11:49:04 +00:00