60 Commits

Author SHA1 Message Date
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
Cosimo Lupo
7d688ff18a
varLib_test: read TTFonts from compiled binary files
instead of importing from TTX, and set lazy=True so we exercise the special SFNTReader.__deepcopy__
2019-01-03 11:26:53 +00:00
Cosimo Lupo
5b250db6cb
varLib_test: test loading master with layerName but without required font object 2019-01-02 13:39:39 +00:00
Cosimo Lupo
ba197cb84c
varLib_test: no need to reload master_ttfs; reuse the reload_font helper func in the other tests 2019-01-02 12:52:57 +00:00
Nikolaus Waxweiler
e464e450ac Make build and load_designspace accept a DS object 2018-12-19 13:40:11 +00:00
Behdad Esfahbod
9c3dde3ce6 [varLib] Always write tuple entries for composite glyphs (#1383)
* [varLib] Always write tuple entries for composite glyphs

Fixes https://github.com/fonttools/fonttools/issues/1381
Fixes https://github.com/googlei18n/fontmake/issues/481 partially

* Make sure at least one gvar delta is written for composites

* Add test data for composite fix

* Put in the correct issue link

* Typo

* Fix typos

* Expand comment, add link to issue

* Add ttx files for test font
2018-12-17 14:03:40 +01:00
ReadRoberts
a460eee80b varLib. Add support for building CFF2 variable font
Fix syntax error reported by build system: can't mix string string types when doing literal concatenation

Fix local import reference - doesn't work in Python3.

Addressed issues raised by @msousa for PR 1345 yesterday.

Will change cff2_merge_funcs.py and cff2mergePen.py from tab to space indentations after the current comments are resolved.

Add various improvements from comments:
- do not edit the post table under varLib.build(). Setting post table format 2 or 3 is now expected to be managed by whatever calls varLib.build().
- In the t2CharStringPen module, rename closure _round() nested in makeRoundFunc to an exportable function, and use it in cff2mergePen.
- remove TypeSupply copyright from cff2mergePen.
- use modulo function to convert float to int when it is meant to be 0 in cff2mergePen.

cff2_merge_funcs.py:merge_PrivateDicts() should only be blending the hint related fields in the PrivateDict. This oversight that was surfaced by @madig reporting an error building his Cantrell font. The bug appeared when the font was subroutinized, as the pen draw method then has to interpret the Subr field in order to access T2Charstring subroutines.

Fix expected ttx output file. When I removed the logic to add glyph names to the post table, glyph names in the ttx file changed.

Miguel prefers a simple list for readability in cff2_merge_funs.py:138.
2018-11-12 11:38:18 -08:00
ReadRoberts
9de373455a varLib. Add support for building CFF2 variable font with a call to varLib.build().
Add test for building CFF2 variable font with a call to varLib.build().

The 'dollar' glyph in the test font is deliberately slightly malformed, with flat curves, in order to exercise the code for dealing with some of the differences in masters designs that can arise from T2 charstring optimization.
2018-11-12 11:38:12 -08:00
Cosimo Lupo
af8c461c92
varLib_test: add test case for GSUB FeatureVariations 2018-09-14 16:51:25 +02:00
Cosimo Lupo
3c59ffda5e
Test: raise DesignSpaceDocumentError when no axes defined 2018-09-11 18:33:53 +02:00
Cosimo Lupo
f3e0cf3604
varLib_test: add tests for --master-dir and -o options 2018-04-25 13:19:58 +01:00