70 Commits

Author SHA1 Message Date
Cosimo Lupo
ecfc5eeeb7
varLib: use sentinel to mark glyph metrics as sparse
as discussed in https://github.com/googlefonts/ufo2ft/issues/501
2023-08-02 14:54:47 +01:00
Cosimo Lupo
653bccdb02
varLib_test: add test for variable CFF2 with empty glyph in sparse master
Three masters, Regular and Bold have glyphs .notdef, a, e; Medium only has .notdef (but empty, no contours) and e.
2023-08-02 14:01:01 +01:00
Cosimo Lupo
b3ce0979cb
Merge pull request #3123 from fonttools/avar2-designspace
[designspace] Add avar2 mapping support
2023-06-08 12:58:51 +01:00
Cosimo Lupo
0690703b86
varLib: add --drop-implied-oncurves option
For the test, I used the Tests/varLib/data/Build.designspace as starting point, modified the 'a' glyph so that 1 on-curve point (the first one) becomes impliable for all the masters.
2023-06-02 15:50:32 +01:00
Behdad Esfahbod
ff7f49a94c [varLib/avar2] Add compile test 2023-05-30 13:13:49 -06:00
Cosimo Lupo
d9570826ad
varLib_test: test build_many doesn't overwrite pre-existing STAT 2023-03-08 12:40:43 +00:00
Cosimo Lupo
5955a47f42
[varLib] build_many(DSv5) from main(); add --output-dir & --variable-fonts options
Fixes https://github.com/fonttools/fonttools/issues/2659
2023-03-07 18:13:28 +00:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Cosimo Lupo
964df076e1 varLib_test: test we don't add no-op DeltaSetIndexMap when not needed
https://github.com/fonttools/fonttools/issues/2800
2022-09-05 17:15:51 +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
bc8f1cfac4 varLib.errors: more informative message with unsupported/inconsistent formats 2022-06-21 17:27:12 +01:00
Cosimo Lupo
4fff281c7e varLib_test: fix expected error message 2022-06-13 12:19:38 +01:00
Khaled Hosny
000bf81700 Default to "\n" for newlinestr instead of None
If newlinestr is None, os.linesep is used, bu it is the third millennium
and we don’t need or want different line endings per-platform.
2021-07-30 04:12:33 +02:00
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
2021-03-29 11:45:58 +02:00
Simon Cozens
23cb8b989b More tests 2021-03-18 21:24:13 +00:00
Simon Cozens
8a6e3087ce Use pytest exception handling 2021-03-17 11:55:51 +00:00
Simon Cozens
0a1aa19c39 Test for better error message 2021-03-15 13:12:11 +00:00
Cosimo Lupo
685b047565 varLib_test: fix failing windows tests
os.path.relpath requires that src and dst be on the same mount drive; GH Actions windows runner create the temporary directory on a different drive than the one where the source is cloned.
2020-11-20 10:06:58 +00:00
Just van Rossum
b992e28374
[varLib] Add designspace lib key for custom feavar feature tag (#2080)
* Add designspace lib key to specify a custom feature tag for feature variations, as discussed in #2079

* Added comment for the lib key

* if the lib key is present, the 'processing' flag should be ignored completely
2020-10-08 14:21:42 +02:00
Cosimo Lupo
cbe84da8c3
varLib_test: comment why font.close() is needed 2020-05-19 10:57:09 +01:00
Cosimo Lupo
a6612aa6b5
varLib_test: close TTFont otherwise shutil.rmtree fails on Win
https://ci.appveyor.com/project/fonttools/fonttools/builds/32948704/job/hc91qjisv4nv603m#L400
2020-05-18 13:16:05 +01:00
Nikolaus Waxweiler
45a8fcefc2
[varLib] Allow feature variations to be active across the entire space (#1957)
* Allow feature variations to be active across the entire space

* Add test with empty condition set

* Skip initial box instead of removing it

* Correct comment
2020-05-15 09:27:15 -07:00
punchcutter
aeb5149f15 Add variable support for BASE table 1.1 2020-03-20 13:34:02 -07:00
Nikolaus Waxweiler
8f7a796bd3 init: Convert existing raised exceptions to new appropriate ones 2020-02-13 14:58:10 +00:00
Nikolaus Waxweiler
eb77a3be22 [varLib] Fill in the forward-mapped location 2020-02-11 15:45:49 +00:00
Cosimo Lupo
1c2fb0e3ef
Merge pull request #1809 from justvanrossum/demo-issue1808
[varLib] demonstrate and fix #1808
2020-02-03 15:39:32 +00:00
Khaled Hosny
38981b6dae [varLib] Allow using CFF2 table as source
Nothing clever, if the source font has a CFF2 table use it as if it were
a CFF table (i.e. non-variable, not sure what would happen in the source
CFF2 was variable already).
2020-01-31 23:39:47 +02:00
justvanrossum
0bb234d218 added test 2020-01-29 12:42:27 +01:00
justvanrossum
92e03c72b2 removed leftovers from previous edit 2020-01-29 12:02:26 +01:00
justvanrossum
69800b0db5 no need to explicitly close: varLib.build() will do that. 2020-01-29 12:01:05 +01:00
justvanrossum
49507a9de8 undo DesignSpaceDocument context manager changes, and explicitly (but opt-out) close master_fonts within varLib.build() 2020-01-29 11:55:39 +01:00
justvanrossum
e18f63cfa3 make DesignSpaceDocument a context manager that closes source fonts, and use it in the varLib tests. 2020-01-29 11:17:57 +01:00
Cosimo Lupo
141ff20b37
varLib_test: test building (pseudo) VF with only a single master
The SingleMaster.designspace contains only one source master, so there is no real
variation data.
Still, and empty HVAR table is added (with RegionAxisCount == fvar.AxisCount).
The gvar and cvar table are not added in this case, since they are empty and
not required.
2019-10-24 14:10:08 +01:00
justvanrossum
e2bac99eb8 Test adding FeatureVariations with an existing 'rclt' feature 2019-10-20 09:19:40 +02:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Cosimo Lupo
1122a2612b
varLib: add set_default_weight_width_slant
When building a variable font, varLib.build must make sure that
the OS/2.usWeightClass is equal to the wght axis default location,
that the OS/2.usWidthClass is set to the equivalent value (1-9) of
the wdth axis default location, and finally that post.italicAngle
is set to the same default value as slnt axis.

Sometimes the base master doesn't have these values correctly
set leading to discrepancies between OS/2 and post, on the one
hand, and the fvar axes' default values.
2019-06-20 12:23:33 +01:00
Cosimo Lupo
8c90878fcf
Merge remote-tracking branch 'origin/master' into fix-singlepos-merge 2019-06-18 15:38:10 +01:00
Cosimo Lupo
eda353c4c1
Merge pull request #1642 from fonttools/CFF2-fixes
Fixes merge bug when VF source have no blends or no marking glyphs in any charstrings.
2019-06-17 16:57:16 +01:00
Nikolaus Waxweiler
bcb0761202 Add test 2019-06-14 10:05:48 +01:00
ReadRoberts
dce80efc7c [varLib.cff] Add test case for CFF2 variable font with no markiing glyphs. 2019-06-12 16:45:08 -07:00
ReadRoberts
73501eda46 [varLib.merger] Add test data for merging GPOS SinglePos subtables 2019-06-12 14:32:25 -07:00
Cosimo Lupo
9e369fa86f
remove unused method in specializer_test and debug prints 2019-05-13 13:00:24 +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
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
ReadRoberts
ecf738b964 Add support for building VVAR table from vmtx and VORG tables.
Add test case.
2019-03-21 10:06:47 -07:00
Nikolaus Waxweiler
8bff72139c Reinstate fixed load_masters() 2019-02-05 13:02:53 +00:00
Nikolaus Waxweiler
1e746e34ee
Revert "load_masters: actually assign font attributes" (#1486)
* Revert "load_masters: actually assign font attributes"

This reverts commit ef1d4cd02d1e46f5dac3914f547a6e4275cf3077, which caused a
crash in `interpolate_layout()` when `deepcopy`ing OTFs.

Amend code and tests while I work on a real fix.
2019-02-05 11:38:46 +00:00
Nikolaus Waxweiler
63a56b98fd _add_MVAR: set model only once, after a tables have been fetched 2019-02-04 16:03:47 +00:00
Cosimo Lupo
7740d1736c
varLib_test: add test for sparse masters 2019-01-16 11:25:29 +00:00
Cosimo Lupo
b2fac2333e
[varLib] allow loading masters from TTX files as well
in a designspace document, the sources' filename attribute can now contain
a relative path to a .TTX file for that master, in addition to .TTF or .UFO
(the latter, resolved through a master_finder callable as before).
2019-01-14 16:32:51 +00:00