34 Commits

Author SHA1 Message Date
Jany Belluz
2ff3159a5f Mark the environment variable as experimental 2021-07-05 17:28:44 +01:00
Jany Belluz
7860dd5fe8 Add tests that optimize block matrices 2021-07-05 17:28:44 +01:00
Jany Belluz
ef67839fdb Fix typing error 2021-07-05 17:28:44 +01:00
Jany Belluz
3b34b228dd Fix fonttools otlLib.optimize command line 2021-07-05 17:28:43 +01:00
Jany Belluz
bba5e8b213 Add optional compaction of GPOS PairPos subtables in otlLib.optimize.gpos
See pull request: https://github.com/fonttools/fonttools/pull/2326

The new module `otlLib.optimize.gpos` provides `compact` functions that
can reduce the file size of GPOS PairPos lookups by splitting subtables
in a smart way to avoid storing zero-valued pairs.

The compaction methods are called from `otlLib.builder` and
`varLib.merger` so that static and variable fonts can benefit from the
optimization at compile time.

The new module `otlLib.optimize` is also executable, to allow running
the optimization on existing fonts.

The optimization is a trade-off because on the one hand it can reduce
significantly the byte size of the GPOS table (up to 50% in random
Google Fonts) but on the other hand it adds to the compilation time and
may make fonts very slightly bigger once compressed to WOFF2 (because
WOFF2 doesn't mind about zero values and compresses them very well).

As such, the optimization is off by default, and you can activate it by
providing the environment variable `FONTTOOLS_GPOS_COMPACT_MODE=5` for
example (values from 0 = off to 9 = max file size savings, but many more
subtables).
2021-07-05 17:28:43 +01:00
Behdad Esfahbod
1e83650db8 [otlLib] Ensure built SinglePos ValueRecords are padded with 0s
Like when they are decompiled.

Part of https://github.com/fonttools/fonttools/pull/2237
2021-03-24 09:26:26 -07:00
Behdad Esfahbod
d961ef5e52 [otlLib] Ensure built PairPos2 ValueRecords are padded with 0s
Like when they are decompiled.

Part of https://github.com/fonttools/fonttools/pull/2237
2021-03-24 09:26:26 -07:00
Cosimo Lupo
b1ca16738c [otlLib] Ensure built PairPos1 ValueRecords are padded with 0s
Like when decompiled.

See 2089d05126 (r48578120)

Part of https://github.com/fonttools/fonttools/pull/2237
2021-03-24 09:25:42 -07:00
Behdad Esfahbod
2a483f9856 [Tests] Fix most test expectations for AlternateSubst .Format removal 2021-03-23 18:01:32 -07:00
Behdad Esfahbod
d6bdfba587 [Tests] Fix more test expectations for SingleSubst .Format removal 2021-03-23 11:43:55 -07:00
Behdad Esfahbod
b62170e86d [Tests] Fix most tests expectations for LigatureSubst .Format change 2021-03-23 11:43:15 -07:00
Behdad Esfahbod
61b06a7fe0 [Tests] Fix most tests expectations for SingleSubst .Format change 2021-03-23 11:43:03 -07:00
Behdad Esfahbod
975f85ed72 [Tests] Fix most tests expectations for Coverage/ClassDef .Format change 2021-03-23 11:42:38 -07:00
Nikolaus Waxweiler
30ade474dd Update test data 2021-03-22 14:45:24 +00:00
Zachary Scheuren
0434b1a917
Add feaLib support for STAT table 2021-02-25 17:16:01 +00:00
Tom Archer
be898ec6f9 Change ValueError to OpenTypeLibError 2021-01-20 14:30:49 +00:00
Tom Archer
9712407054 Change TypeError to ValueError 2021-01-20 11:19:43 +00:00
Tom Archer
7c6337facf Add exception and test 2021-01-19 17:57:53 +00:00
Simon Cozens
e3e12fe60d Fix mock builder test 2020-07-22 14:20:50 +01:00
Simon Cozens
85edf0e380 Use the ChainContextualRule class instead of bare tuples 2020-07-22 14:20:50 +01:00
Simon Cozens
b6f7b2dc4b Stylistic fixes from feedback 2020-07-11 19:54:52 +01:00
Simon Cozens
bc0f69884e Thinko 2020-07-07 13:28:44 +01:00
Simon Cozens
9f4cc2f1cb Introduce the concept of a ClassContextualRuleSet
Currently unused but will be super helpful for optimizing the formats of contextual lookups.

* Splits the rules of a class contextual lookup based on explicit subtable breaks
* Returns various properties on the ruleset to help determine appropriate layout format.
* (More properties, such as "touched glyphs", planned - will be added when needed.)
2020-07-07 12:44:25 +01:00
Simon Cozens
3b50a533d5 otlLib now sets this flag itself. 2020-07-03 12:37:22 +01:00
Simon Cozens
ebfa4ba1fe
Move feature builders to otlLib
Refactors feaLib, moving code which builds OpenType lookups into otlLib. Note that this changes feaLib's concept of `location` from a tuple to an object.
2020-07-02 14:09:10 +01:00
Just van Rossum
90c7c7fae1
Fix for #1985: ensure that the AxisNameID in the STAT table is > 255 (#1986)
Fix for #1985:
* ensure that the AxisNameID in the STAT table is not less than 256. This needed an additional argument to the addMultiLingualName() name table method.
* fvar axis name IDs must also not be less than 256, just like STAT axis names.
2020-06-08 19:39:28 +02:00
Just van Rossum
d6bb38c7e6
[otlLib.builder] Add function to build STAT table from high-level description (#1926)
* added a function to build a STAT table: `fontTools.otlLib.builder.buildStatTable()`
* make `varLib._add_stat()` a client of `buildStatTable()`
2020-05-09 16:08:11 +02:00
Simon Cozens
ab075a9957 Annotate LookupFlag ttx dump 2020-03-10 21:42:28 +00:00
Marc Foley
4e316cae57 [name] add removeNames method to table__n_a_m_e 2019-09-11 11:56:09 +01:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Cosimo Lupo
18f969ab7d
otlLib_test: convert to using pytest-style tests 2019-06-20 15:33:53 +01: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
Martin Hosken
27d8d1bda0 Update tests 2019-03-15 11:16:51 +07:00
Cosimo Lupo
78ad48eaf3
Move all *_test.py modules and test data to external Tests/ folder 2017-01-16 09:14:12 +00:00