692 Commits

Author SHA1 Message Date
Cosimo Lupo
9d895be4d5
instancer_test: add test for composite glyph without variations
We assert that the composite glyph's sidebearings and bbox are updated when its parent glyph
has changed.
The tests will fail, but a fix will follow shortly.
2019-06-06 13:33:57 +01:00
Cosimo Lupo
1722f99182
PartialInstancer-VF.ttx: add composite glyph and vhea table
the glyph 'minus' references 'hyphen' as component, but doesn't have any deltas in gvar.

vhea table is required when vmtx is present.
2019-06-06 13:30:21 +01:00
Cosimo Lupo
0abf6a8295
instancer_test: always dump test ttx files with '\n' 2019-05-31 20:08:50 +01:00
Cosimo Lupo
11b73034d7
instancer_test: read expected test file with unix newlines '\n'
or windows isn't happy..
2019-05-31 20:03:52 +01:00
Cosimo Lupo
8c3bfe5475
ttx: use caplog fixture instead of capsys
this capture logging messages whereas capsys captures stdout/stderr
2019-05-31 19:58:02 +01:00
Cosimo Lupo
499d97464d
instancer_test: use caplog fixture 2019-05-31 19:57:53 +01:00
Cosimo Lupo
3d5f5c0a36
Tests/conftest.py: disable fontTools.configLogger globally during tests
otherwise it causes sides effects since logging state is global and should only
be done when __name__ == '__main__'.

We can capture logging messages via the caplog pytest fixture
2019-05-31 19:57:52 +01:00
Cosimo Lupo
b0ede1a3c6
instancer_test: add tests for normalizeAxisLimits function
coverage is now 97%, good enough
2019-05-30 14:10:26 +01:00
Cosimo Lupo
68bbc74a78
instancer_test: add tests for main() function 2019-05-30 13:56:58 +01:00
Cosimo Lupo
b528ff67f0
instancer_test: add unit tests for parseLimits 2019-05-30 13:35:56 +01:00
Cosimo Lupo
b878b867c0
instancer: don't break on unsupported condition formats
continue checking subsequent condition tables in case the other may
be format=1 and may reference a pinned axis; in which case, these
conditions need to be dropped from the condition set, or the whole
record needs to be dropped if the instance coordinate is outside the
condition range.
Condition tables within a condition set are associated with a AND
boolean operator, so if any one doesn't match, the whole set doesn't
apply. Even if we don't recognize one condition format, if we do
ascertain that another condition table does not match the current
partial instance location, we can drop the FeatureVariation record
since it doesn't apply.
2019-05-30 13:13:06 +01:00
Cosimo Lupo
874947c00b
instancer_test: make new test font with FeatureVariations
instead of reading off existing FeatureVars.ttx test file.
This gives us more flexibility to add more tests, and keeps the input
values closer to the expected results
2019-05-30 13:13:06 +01:00
Cosimo Lupo
36f2775d6c
instancer: always keep FeatureVariationRecords with unknown condition format
there was a logic issue in the function that checks whether a FeatureVariationRecord
has a unique set of condition (was returning False instead of True for unsupported condition).
It's safer to always keep such records with unknown condition formats as new formats
may be added in the future. A warning is already issued in these cases.
2019-05-30 11:22:01 +01:00
Cosimo Lupo
3560267a0b
instancer_test: add tests for instantiateFeatureVariations
using the same test file FeatureVars.ttx used by varLib_test.py
2019-05-29 19:24:02 +01:00
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
Miguel Sousa
9fb0cac564 fontBuilder: Don't add a stub signature to DSIG
An empty DSIG is enough to make MS applications happy and also fixes an error reported by MS Font Validator
2019-05-25 10:09:13 -07: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
Khaled Hosny
2861d65e56 [subset] Update font extents in head table
When --recalc-bounds option is used the font extents in the head table
need to be updated, but since tables are lazy-loaded by default the
table will not be recompiled and will keep the old value. Force
recompiling the table by adding it to prune_post_subset tables, though
I’m not 100% sure this is the best approach.
2019-05-17 21:10:11 +02:00
Garret Rieger
dce15980fd Make --retain-gids truncate empty glyphs after the last non-empty glyph. 2019-05-16 10:13:33 -07: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
96c81ebd8a
Merge pull request #1598 from fonttools/update-OTF-testfonts
Convert OTF font files in test data to ttx files.
2019-05-13 13:09:37 +01:00
Cosimo Lupo
9e369fa86f
remove unused method in specializer_test and debug prints 2019-05-13 13:00:24 +01:00
Cosimo Lupo
44f74dc8bb
designspaceLib: add loadSourceFonts method with custom opener
Allows to load the SourceDescriptor.font attribute from its path, using a custom callable (e.g. defcon.Font or ttLib.TTFont, etc.).
2019-05-10 16:32:11 +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
Khaled Hosny
dadec23978
Merge pull request #1599 from khaledhosny/fealib-valuerecord-asfea
[feaLib] don’t write None in ast.ValueRecord.asFea()
2019-05-03 11:20:33 +02:00
Khaled Hosny
b1999a1a0e Add test for previous commit 2019-05-03 01:14:09 +02:00
Khaled Hosny
41c7760be3 [feaLib] don’t write None in ast.ValueRecord.asFea()
The code tries to write the short format when some values as None, but
when writing the long format it would write any None value as is which
is invalid, use 0 for None values instead.
2019-05-03 00:53:09 +02: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
Miguel Sousa
9cbfef1972
Merge pull request #1588 from fonttools/hvar-vvar-retain-gids
[subset] HVAR/VVAR with --retain-gids
2019-04-26 06:55:17 -07:00
Miguel Sousa
45596108e2 (Re)calculate OS/2.usMaxContext value
The value is only modified in the context of fontBuilder or subset. It will NOT be modified when using ttx.

maxContextCalc.py was copied from https://github.com/googlefonts/ufo2ft/blob/master/Lib/ufo2ft/maxContextCalc.py

Fixes #1191
Fixes #466
2019-04-24 18:31:12 -07:00
Michiharu Ariza
00dddb1c32 fixed non retain-gids with no AdvWidthMap behavior
deltas in VarData[0] are directly look up by GID so compacted
if any deltas are referenced by LsbMap / RsbMap but not used for advance widths, they are moved to the end of VarData[0]

updated expected test result expect_HVVAR.ttx accordingly
2019-04-24 16:46:21 -07:00
Michiharu Ariza
f028c75d2a issue #1587: AdvWidthMap null with Lsb/RsbMaps non-null
along with tests
2019-04-23 17:03:04 -07:00
Cosimo Lupo
fe1fb45eff
Merge remote-tracking branch 'origin/master' into partial-instancer 2019-04-20 17:51:56 +01:00