173 Commits

Author SHA1 Message Date
Cosimo Lupo
e2c0acf1c2
Merge remote-tracking branch 'origin/master' into partial-instancer 2019-05-29 18:04:54 +01:00
Cosimo Lupo
8f88131a78
FeatureVars.ttx: fix up expected test results after aa8a5bc 2019-05-29 13:48:11 +01:00
Cosimo Lupo
6efc66e0fc
instancer_test: test instantiateVariableFont main function
Added new test VF font (a subset of NotoSans-VF only containing glyphs 'A', 'Agrave' and 'T');
the VF was instanced with varLib.mutator, producing a series of full instances, which are
included as ttx files as well.
The tests run the partial instancer twice, once only instancing wght, then again for wdth,
and assert that the generated instance is identical to those.
2019-05-21 18:42:39 -04:00
Cosimo Lupo
4051976f48
Merge remote-tracking branch 'origin/master' into partial-instancer 2019-05-21 14:54:42 -04:00
Khaled Hosny
7e5644a0a8 [varLib] Fix merging GDEF.GlyphClassDef in mutator
The code was setting GlyphClassDef.classDefs for the base font to an
empty dict then reading it from all fonts. It accidentally works when
creating variable fonts because the GlyphClassDef of the other fonts
will be used, but when mutating there is only one font.

Fix by reading the glyph classes before assigning to an empty dict.
2019-05-18 04:44:34 +02:00
Cosimo Lupo
27a8ba480d
Merge remote-tracking branch 'origin/master' into partial-instancer 2019-05-15 13:09:19 -04:00
Cosimo Lupo
6b297076a4
varLib_test: update test TTX so they keep glyph names 2019-05-13 13:12:46 +01:00
Cosimo Lupo
9e369fa86f
remove unused method in specializer_test and debug prints 2019-05-13 13:00:24 +01:00
Cosimo Lupo
d9ad9d8ef5
instancer: set OS/2 weight/width and post.italicAngle 2019-05-08 18:46:43 +01:00
Cosimo Lupo
5871a754de
instancer: set mac overlap glyf flags when fully instancing
like varLib.mutator does
2019-05-08 17:23:24 +01:00
Cosimo Lupo
5a530880c0
instancer: prune unused name records after instancing 2019-05-08 11:38:38 +01:00
Cosimo Lupo
0010a3cd9a
instancer: return default deltas as floats from instantiateTupleVariationStore
Do not round them to integer, but let the caller do the rounding immediately before adding them to the default instance (or just before compiling the binary table as with glyf).

This ensures that the glyphs' left sidebearings are calculated in the same way as they were by varLib.mutator.
If we round deltas too early, then we may get off-by-one differences.
See the glyf table setCoordinates method where left sidebearings are computed.
2019-05-07 14:05:27 +01:00
Cosimo Lupo
89ce41be55
instancer_test: add test for instantiateSTAT
added a dummy STAT table to PartialInstancer-VF.ttx font that has all 4 AxisValue formats.
It doesn't have contain AxisValue for each fvar NamedInstance like the spec recommends, but it's ok for the sake of this test
2019-05-03 13:32:06 +01:00
ReadRoberts
77f72bc62b Convert OTF font files in test data to ttx files.
This required a fix to fontTools/cffLib. When reading a CFF2 variable font (VF) from XML, the VF state in FontDict and PrivateDict does not get set. I made a temporary fix by adding a loop to set PrivateDict.vstore for all the PrivateDict objects after the XML file has been read. This should not be necessary, and in the near future I will revisit both this issue, and the related use of isCFF2 when compiling/decompiling.
2019-05-01 16:01:43 -07:00
Cosimo Lupo
8eed2a2ec0
instancer_test: add test for instantiateFvar 2019-05-01 15:54:58 +01:00
Cosimo Lupo
c8d82e809d
instancer_test: add test for instantiateAvar 2019-05-01 15:48:00 +01:00
Cosimo Lupo
cbf1a854ee
instancer_test: fix MVAR/HVAR tests now that pinned VarRegionAxis are dropped 2019-05-01 15:48:00 +01:00
Cosimo Lupo
2a1e6a1fd5
instancer_test: test instancing HVAR table
Aldo added AdvWidthMap to PartialInstancer-VF.ttx test font
2019-04-29 12:51:34 +02:00
Cosimo Lupo
002de44c13
instancer_test: add vmtx to PartialInstancer-VF.ttx
used in gvar unit tests in instancer_test.py
2019-04-29 12:51:34 +02:00
Cosimo Lupo
1b5393acdd
instancer: call optimize() after instantiateItemVariationStore, not inside
for HVAR/VVAR without indirect mappings, we can skip calling VarStore.optimize() and
keep a direct mapping from GID to VarIdx
2019-04-29 12:51:33 +02:00
Cosimo Lupo
aacbc7153d
instancer: capitalise 'MVAR' in method names 2019-04-29 12:51:33 +02:00
Cosimo Lupo
f74e82fec5
Merge remote-tracking branch 'origin/master' into partial-instancer 2019-04-29 12:47:37 +02:00
Read Roberts
5b3db36670
Sparse cff2vf support (#1591)
* Added getter (in the form of a property decorator) for T2Charstring.vsindex. Fixes endless compile loop in some circumstances.

Fixed bug in mutator: need to remove vsindex from snapshotted charstrings, plus formatting clean up

* Fix for subsetting HVAR tables that have an AdvanceWidthMap when the --retain-gid option is used. Needed to make subset_test.py::test_retain_gids_cff2 tests pass.

* in varLib/cffLib.py, add support for sparse sources, and sources with more than one model, and hence more than one VarData element in the VarStore.

CFF2 source fonts with multiple FontDicts in the FDArray need some extra work. With sparse fonts, some of the source fonts may have a fewer FontDicts than the default font. The getfd_map function() builds a map from the FontDict indices in the default font to those in each region font. This is needed when building up the blend value lists in the master font FontDict PrivateDicts, in order to fetch PrivateDict values from the correct FontDict in each region font.

In specializer.py, add support for CFF2 CharStrings with blend operators. 1) In generalizeCommands, convert a blend op to a list of args that are blend lists for the following regular operator. A blend list as a default font value, followed by the delta tuple. 2) In specializeCommands(), convert these back to blend ops, combining as many successive blend lists as allowed by the stack limit.

Add test case for sparse CFF2 sources.
The test font has 55 glyphs. 2 glyphs use only 2 sources (weight = 0 and 100). The rest use 4 source fonts: the two end points of the weight axis, and two intermediate masters. The intermediate masters are only 1 design space unit apart, and are used to change glyph design at the point in design space. For the rest, at most 2 glyphs use the same set of source fonts. There are 12 source fonts.

Add test case for specializer programToCommands() and commandsToProgram by converting each CharString.program in the font to a command list, and back again, and comparing original and final versions.
2019-04-26 09:33:52 -07:00
Cosimo Lupo
544f6aae43
instancer_test: add test for instancing GPOS with kern and mark features 2019-04-18 17:37:08 +01:00
Cosimo Lupo
9aa5407f31
instancer_test: add tests for instatiating GDEF ligature carets 2019-04-18 13:17:37 +01:00
Cosimo Lupo
dc14a50029
minor: autoformat 2019-04-18 13:11:33 +01:00
Cosimo Lupo
f742738949
instancer: partially instantiate GDEF and GPOS 2019-04-18 10:49:13 +01:00
Cosimo Lupo
8aa57fef81
instancer: convert item to tuple varstore to reuse same partial istancing code 2019-04-18 10:17:54 +01:00
Cosimo Lupo
4a7ab3fee2
instancer: use VarStore.optimize() and remap MVAR records' VarIdx
in test font, add additional VarData subtable in MVAR.VarStore and check it gets merged after optimizing.
2019-04-16 11:23:39 +01:00
Cosimo Lupo
d9b7b79bca
instancer_test: test gvar full instancing with optimize=True 2019-04-15 18:39:49 +01:00
Cosimo Lupo
82085f5ea8
instancer: must redo iup_delta_optimize if the default coordinates have changed
If we modify the default instance coordinates, then the inferred deltas that
are left in gvar are no longer valid, so we need to calculate them using the
original default coordinates.
They are then re-optimized using the modified default coordinates.

Also, the default deltas returned from instantiateTupleVariationStore are now
already rounded to integer.
2019-04-04 15:11:23 +01:00
Cosimo Lupo
f220d36df1
instancer: merge TupleVariations left with same axes after pinning
The instantiateTupleVariationStore function now groups TupleVariation
tables that have the same axes 'tents', then merges them into a single
TupleVariation by summing their deltas. The rounding to integer happens
after summing the scaled deltas as floats, to reduce off-by-one errors.

To be able to sum gvar TupleVariation, it needs to calculate the inferred
deltas so it now takes two optional lists (origCoords and endPts) that
are passed on to iup_delta function. These only make sense for gvar
type of TupleVariation, of course, and are unused for cvar tuples.

It also run iup_delta_optimize on the gvar deltas that are left after
partial instancing and whose inferred deltas had to be interpolated.
This can be disabled with --no-optimize CLI option.

Also added calcInferredDeltas and optimize methods to TupleVariation
class, which use functions from varLib.iup module, plus tests
that exercise them.
2019-04-04 15:11:23 +01:00
Cosimo Lupo
fb914c93c4
Merge remote-tracking branch 'origin/master' into partial-instancer 2019-04-04 14:15:14 +01:00
Cosimo Lupo
8e9fac123c
instancer_test: add more unit tests for instantiateItemVariationStore 2019-03-29 13:00:27 +00:00
Cosimo Lupo
a8853997d5
instancer_test: start adding tests for instantiateItemVariationStore helpers 2019-03-28 19:32:05 +00:00
Cosimo Lupo
e6033a14da
instancer: drop region if axis scalar is 0
update VarData.VarRegionCount

also set StartCoord and EndCoord to 0 (same end result as only setting PeakCoord
to 0, but this produces less noise when inspeciting the generated XML dump)
2019-03-26 18:44:50 +00:00
Cosimo Lupo
2b746d6e50
instancer: unpack axis (start, peak, end) tuple instead of indexing at PEAK_COORD_INDEX
Makes it more readable
2019-03-25 13:41:41 +00:00
Cosimo Lupo
012d80db6d
instancer_test: added tests for MVAR table
I added an MVAR table to the PartialInstancer-VF.ttx test font with made-up deltas for
OS/2.yStrikeoutSize, post.underlinePosition and post.underlineThickness.
I defined 3 regions, one with only wght, one with only wdth, and one with both wdth and wght axes.
2019-03-25 13:19:38 +00:00
Cosimo Lupo
eff5a6310d
instancer_test: adjust expected cvar test result 2019-03-25 12:22:42 +00:00
Cosimo Lupo
05c22b9122
instancer_test: added tests for instantiateCvar 2019-03-25 11:09:46 +00:00
ReadRoberts
ecf738b964 Add support for building VVAR table from vmtx and VORG tables.
Add test case.
2019-03-21 10:06:47 -07:00
Cosimo Lupo
6281f87cb6 rename partialInstancer.py to instancer.py 2019-03-21 15:30:48 +00:00
Cosimo Lupo
126a2d9c38 Add partialInstancer_test.py and PartialInstancerTest-VF.ttx
Currently tests the instantiateGvar function only.
The test font contains two axes and a single glyph.
I shall make add more complexity later.
2019-03-12 19:44:33 +00:00
Cosimo Lupo
df3bbbb7ad varLib: use hhea.ascent and head.unitsPerEM for phantom pts when vmtx missing
https://github.com/anthrotype/fonttools/pull/new/gvar-vmtx-phantom-pts
2019-03-05 10:02:35 -08:00
Cosimo Lupo
cf9f866943 varLib: fix expected test results after bottomSideY changed sign 2019-03-04 18:41:43 -08:00
Cosimo Lupo
71e44a52ee TupleVariation.toXML: sort attrs min/value/max in TTX dump
It's more legible if the peak value is written after the min and before the max value
defining a given region.
2019-03-04 16:41:26 -08:00
Cosimo Lupo
c813b65d32 models_test: test default 0.0 input locations are omitted internally 2019-03-04 12:38:32 -08:00
Cosimo Lupo
0811834b3c models_test: VariationModel input locations should be in normalized space
not only base should be at 0, but min/max respectively at -1.0 and +1.0.
that's how varLib constructs models internally, so update test case to reflect that
2019-03-04 12:31:08 -08:00
Cosimo Lupo
05824b8616 VariationModel: assert that locations are unique 2019-03-04 11:42:54 -08:00
Cosimo Lupo
b9aa815d06 models_test: bundle test methods under VariationModelTest class
in preparation for adding more unit tests to VariationModel class.
2019-03-04 11:03:34 -08:00