34 Commits

Author SHA1 Message Date
Behdad Esfahbod
cfba1f995f [cffLib.specializer] Make command-merging linear again
The consideration for blends had made it into O(n^2).
Make it linear again.

Speeds up Tests/cffLib/specializer_test.py::CFFSpecializeProgramTest::test_maxstack_blends
3x for me.
2024-11-12 18:43:03 -07:00
Behdad Esfahbod
7e6d31569f [cffLib.specializer] Adjust stack use calculation
See comment.
2024-11-12 17:47:52 -07:00
Behdad Esfahbod
bb7a29e81a [cffLib.specializer] Fix more stack-overflow opportunity
I think it's solid now.
2024-11-06 19:13:35 -05:00
Behdad Esfahbod
2e96d81b05 [specializer_test] Add a test for blend stack-use after specialize() 2024-11-06 18:25:03 -05:00
Behdad Esfahbod
3a909a07fa [specializer_test] Parametrize copy/pasta tests 2024-11-06 17:49:52 -05:00
Behdad Esfahbod
49bcd19bd9 [specializer_test] Remove Python2 remnants 2024-11-06 16:23:58 -05:00
Behdad Esfahbod
1536efc22e [CFFToCFF2] Add a test
Exercises:
https://github.com/fonttools/fonttools/pull/3518#discussion_r1611033728
2024-05-25 10:15:00 -06:00
Behdad Esfahbod
43b16df8db [avar] Update test expectations 2023-03-08 11:10:07 -07:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Behdad Esfahbod
975f85ed72 [Tests] Fix most tests expectations for Coverage/ClassDef .Format change 2021-03-23 11:42:38 -07:00
Khaled Hosny
6cb0a56020 [cffLib] Make sure glyph names are unique
Similar to what we do with “post” table names. I’d have said the font is
broken, but all applications I tried it with loaded it just fine, though
they differed in which glyph to pick from the duplicate ones.

Fixes https://github.com/fonttools/fonttools/issues/1602
2019-08-17 12:51:31 +02:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Khaled Hosny
71ea0cbe07
Merge pull request #1677 from fonttools/fdselct-format-4
[cffLib] Support FDSselect format 4
2019-08-02 01:05:27 +02:00
Khaled Hosny
ad4bb343fc [cffLib] Support FDSselect format 4
Introduced in CFF2 table, but code does not limit it to CFF2 table. If
FDSelect format is set to 4, it will be read/written regardless of the
table version.
2019-08-01 21:28:46 +02:00
Read Roberts
4ee5e6da16 [cffLib specializer] Fix bug in programToCommands with CFF2 charstrings
When checking if there was an initial width argument, old logic did not correctly sum the number of blend and non-blend arguments before the first hint or moveto operator.

Added test case. Old logic dropped the arguments for the hmoveto in the last glyph.
2019-07-30 20:25:38 -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
Nikolaus Waxweiler
e50733df21 Make simpler test in cffLib tests 2019-02-05 14:33:58 +00:00
Kunihiko Sakamoto
35377bc93b Fix test 2018-07-25 18:22:18 +09:00
Miguel Sousa
d401b2522b [cffLib_test] Test setting topDict.Encoding
#1177
2018-02-23 03:02:06 -08:00
Miguel Sousa
299dbcbe14 [cffLib_test] use boilerplate class; change class and method names 2018-02-23 03:02:06 -08:00
Masaya Nakamura
b22b59f730 [cffLib] Use intRect() for FontBBox rounding
AFDKO seems to calculate bounds and side bearings in this manner.
2017-08-01 10:51:47 +09:00
Masaya Nakamura
b84ee6744d [cffLib] Recalc CFF's FontBBox when compiling 2017-08-01 10:51:47 +09:00
Miguel Sousa
0d894c6ec2 [cffLib.specializer_test] Resolve conflicts 2017-05-31 17:20:34 -07:00
Miguel Sousa
5d981cae0a [cffLib.specializer_test] Additional tests 2017-05-08 15:49:56 -07:00
Miguel Sousa
3c29ff73a7 [cffLib.specializer_test] Tests for missing arguments 2017-05-08 15:49:47 -07:00
Miguel Sousa
1d3ac1add4 [cffLib.specializer_test] TODO 2017-05-08 15:49:39 -07:00
Behdad Esfahbod
30b804003e [cffLib.specializer] Add programToString and stringToProgram from _test.py 2017-05-07 22:12:19 -06:00
Behdad Esfahbod
a8b841a4a9 [cffLib.specizalier_test] Add a few more tests 2017-05-07 22:04:17 -06:00
Behdad Esfahbod
041384a0e8 [cffLib.specializer_test] Add tests for peephole optimization 2017-05-07 13:08:41 -06:00
Miguel Sousa
2f14200a89 [cffLib.specializer_test] specializeProgram tests
The failing tests are due to missed optimization opportunities.
The current tests are not hitting some edge cases.
2017-05-07 03:14:24 -07:00
Miguel Sousa
2f7f36e2f4 [cffLib.specializer_test] charstring extras 2017-05-07 00:23:12 -07:00
Miguel Sousa
9617f5f26b [cffLib.specializer_test] generalizeProgram tests 2017-05-06 22:57:37 -07:00