5720 Commits

Author SHA1 Message Date
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
e84bee9cd9 Set bits only after updating names 2022-07-05 16:10:15 +01:00
Nikolaus Waxweiler
2c773441cf Remove logging 2022-07-05 16:09:37 +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
5d52124e49 varLib.errors: allow to give extra context as to where an error occurs in the optional 'cause' 2022-07-04 18:52:20 +01:00
Cosimo Lupo
4b9f35dc2b varLib.merger: subset self.ttfs to non-None (sparse) values in VariationMerger.mergeThings 2022-07-04 18:52:20 +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
eb00e499c0 colorLib: factor out LayerReuseCache class 2022-07-04 12:40:47 +01:00
David Corbett
8ec37c4bb3 [feaLib] Let the parser set nameIDs 1 through 6 2022-07-02 15:23:03 -04:00
Nikolaus Waxweiler
a3e14643a1 Set RIBBI bits when cutting instances 2022-06-30 18:56:03 +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
10140f9df3 Remove TODO. 2022-06-27 18:32:04 +00:00
Garret Rieger
8196166e53 Add some additional comments about packing state machine. 2022-06-27 18:28:02 +00:00
Garret Rieger
d92fd2665c Use enum's for repacker state. 2022-06-27 18:18:20 +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
99a754a48e varLib/merger.py: (minor) rename self.varTables => self.varTableIds 2022-06-27 15:54:51 +01:00
Cosimo Lupo
4ca582a273 otTraverse: add pretty __str__ for SubTablePath tuple
so one can debug print(path) and get things like 'Paint.Paint.ColorLine.ColorStop[1]'
2022-06-24 18:33:52 +01:00
Cosimo Lupo
f02593cf1a COLRVariationMerger: fix logic in convertSubTablesToVarType
Before we were too greedy in the way we converted subtables to VarType. E.g. If a PaintTransform wrapping a PaintRadialGradient contained variations in the Affine2x3, we would incorrectly convert also the gradient's ColorLine (and ColorStops) to VarColorLine, VarColorStop, etc. (even if the gradient was not variable!). Instead we want skip traversing a given subtable including its children when the predicate doesn't match.
2022-06-24 18:14:58 +01:00
Cosimo Lupo
41943bb0e7 otTraverse: add options to skip_root and predicate to filter out entire sub-trees 2022-06-24 18:04:04 +01:00
Cosimo Lupo
a53a235302 varLib.merger: set Paint.Format to int(PaintFormat)
for consistency with the way tables are decompiled from binary data
2022-06-24 11:36:58 +01:00
Cosimo Lupo
7ab7940761 varLib: simplify a bit following varStore.py recent changes
#2662
2022-06-24 10:20:48 +01:00
Cosimo Lupo
fcd2a67f52 Merge remote-tracking branch 'origin/main' into variable-colr 2022-06-24 10:16:51 +01:00
Garret Rieger
c63b84db7e Update how table packing falls back to fontTools from harfbuzz.
Introduce three compilation modes:
1. Pure python: only uses the existing fonttools packing and overflow resolution.
2. Harfbuzz+python: uses harfbuzz packing and python overflow resolution. Extensions are allowed to be shared.
3. Python fallback: if harfbuzz+python runs out of resolution options, this disables extension sharing and only uses python packing. Once it succeeds control is passed back to the harfbuzz packer to produce the final packing with extension sharing enabled.
2022-06-23 19:39:56 +00: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
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
Behdad Esfahbod
cac7241514 [varLib.varStore] Add NO_VARIATION_INDEX
Part of https://github.com/fonttools/fonttools/issues/2211
2022-06-23 12:01:20 -06:00
Cosimo Lupo
0e6a4ec581 [otBase] temporarily disable extension sharing during harfbuzz repacking
If extension sharing is enabled some fonts may fail to repack due to fontTools repacker getting stuck in a unrecoverable error.

https://github.com/fonttools/fonttools/issues/2661
2022-06-23 16:34:12 +01:00
Simon Cozens
d224e1f73d
[feaLib] show all missing glyphs at once (#2665) 2022-06-23 15:04:59 +01:00
Behdad Esfahbod
e917c43ca9 [varLib.varStore] Add operator __bool__ and use it
Part of https://github.com/fonttools/fonttools/issues/2211#issuecomment-790125437
2022-06-21 14:03:20 -06:00
Cosimo Lupo
9c0bc3814f varLib: add --no-colr-layer-reuse option to disable rebuilding LayerList 2022-06-21 17:27:12 +01:00
Cosimo Lupo
00959d3132 varLib: build variable COLR table when master fonts contain COLRv1 2022-06-21 17:27:12 +01:00
Cosimo Lupo
e58c43d187 varLib.merger: add a COLRVariationMerger to merge multiple master COLRv1 into a variable COLR 2022-06-21 17:27:12 +01:00
Cosimo Lupo
24941e613f otTraverse: add module containing methods for traversing trees of otData tables
this is adapted from nanoemoji's
d65a627154/src/nanoemoji/util.py (L122-L162)
2022-06-21 17:27:12 +01:00
Cosimo Lupo
fae63959a9 otTables: add class attributes to link Var{Table} <-> {Table}
so one can go from Affine2x3 <-> VarAffine2x3 and similar types that have an associated Var{Type}
2022-06-21 17:27:12 +01:00
Cosimo Lupo
ca2f9e0a94 otBase: use OptionalValue.DEFAULT in populateDefaults() 2022-06-21 17:27:12 +01:00
Cosimo Lupo
bc8f1cfac4 varLib.errors: more informative message with unsupported/inconsistent formats 2022-06-21 17:27:12 +01:00
Cosimo Lupo
fa54b0fd62 otTables: add methods to Format enums to query the variable variants 2022-06-21 17:27:12 +01:00
Cosimo Lupo
97bcda9d35 otBase: define method to get variable attrs with associated VarIndexBase + {offset} 2022-06-21 17:27:11 +01:00
Cosimo Lupo
396353e8e3 otConverters: parse 'VarIndexBase + {offset}' from converters' description 2022-06-21 17:27:11 +01:00
Cosimo Lupo
871ee3d527 otData: add 'VarIndexBase + {offset}' to description of all COLR variable fields 2022-06-21 17:27:11 +01:00
Cosimo Lupo
82460bd368 otConverters: define a base class for all fixed-size floats with toInt/fromInt methods
this will be useful when computing deltas for COLR table fields that use Fixed or F2Dot14 (ItemVariationStore internally treats fixed-value floats as 16 or 32-bit integers)
2022-06-21 17:27:11 +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
0cbdc8536b [otBase/varLib.merger] don't recurse in ensureDecompiled, merger is already working recursively 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
Cosimo Lupo
fc982c643b colorLib: add option to disable PaintColrLayers' reuse of layers from LayerList
When building COLR masters, layer reuse may lead to different number of layers between masters, becasue some master may reuse specific layers while others may not. Add a flag to disable this optimization; will need to be run again after the VF COLR font has been merged
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
Jens Kutilek
d0020b2536
Add check for missing glyphs to featureVars (#2654)
* Add check for missing glyphs to featureVars
2022-06-17 15:24:54 +02:00
Cosimo Lupo
c34ff0d474 [varLib.merger/errors] fix undefined exception name
The exception UnsupportedFormat was defined and then redefined with the same name in varLib.errors, and imported twice from varLib.merger, probably as result of a sweeping find/replace.
Rename it 'InconsistentFormats' as originally intended.
2022-06-17 11:24:56 +01:00