54 Commits

Author SHA1 Message Date
David Corbett
aa390ec98b Fix OS/2.usMaxContext for reverse GSUB rules 2024-06-16 20:37:17 -07:00
Khaled Hosny
0f953cccd8 [otlLib] Support building MATH table 2024-02-14 02:48:13 +02:00
Cosimo Lupo
f96b2128a1
[feaLib] keep declaration order of ligatures within ligature set
Fixes #3428
2024-01-24 12:59:00 +00:00
Cosimo Lupo
2c07619344 [otlLib] make ClassDefBuilder class order match varLib.mergers
see https://github.com/fonttools/fonttools/blob/c3d876/Lib/fontTools/misc/classifyTools.py#L77

i.e. we want (large classes first, then lexicographic order on the glyphs); previously otlLib was sorting by the _reverse_ of (small classes first, then glyphs lexicographic order) -- effectively comparing the reverse of the glyph sets of classes of the same size.

Fixes https://github.com/fonttools/fonttools/issues/3321

note the ttx dump of previously built fonts may change but there won't be any functional changes.
2023-11-02 16:36:48 +00:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Jany Belluz
268fbac85c [config] Add tests 2022-04-14 15:23:22 +01:00
Olli Meier
86e4795405 As requested: black Tests/otlLib/builder_test.py 2022-02-11 15:58:34 +01:00
Olli Meier
3b1fac049d Renamed unittest as requested by anthrotype 2022-02-11 15:56:03 +01:00
Olli Meier
68fa3bbd47 Cleaning code based on feedback from Just 2022-02-10 22:13:58 +01:00
Olli Meier
e968e8fd7f Based on the discussion with Just and anthrotype: Undo the changes in the name table and extend unittests. If there are inconsistencies in the name table, it's ok to create new name IDs, even if this might not be the most efficient way of creating the name table. 2022-02-10 21:24:51 +01:00
Olli Meier
ad1d82f810 Some more changes. Not sure about this. 2022-02-10 17:56:42 +01:00
Olli Meier
51eda21b0a Adding more unittests, based on feedback. 2022-02-10 17:11:26 +01:00
Olli Meier
6bf842a30e Reduce unittest content and update description. 2022-02-10 16:31:17 +01:00
Olli Meier
9028a53d3b based on feedback 'anthrotype' I use 'windowsNames' and 'macNames' in STAT table functions and 'windows' and 'mac' in name table functions. 2022-02-10 15:57:56 +01:00
Olli Meier
6014cd8ae5 based on Just Van Rossum's feedback: replace variables. 2022-02-10 15:39:51 +01:00
Olli Meier
7f21d5eee3 adding variable platforms 2022-02-10 15:14:20 +01:00
Olli Meier
0f17da0836 Bugfix: The script to create a STAt table created multiple unnecessary name table entries, because it did not take care a bout existing entries with the same name. 2022-02-10 13:44:42 +01:00
Olli Meier
62bc692da1 adding description 2022-02-10 13:09:27 +01:00
Olli Meier
01ba5394fb Create failng unittest first. 2022-02-10 13:07:37 +01:00
David Corbett
cfa69f245f [otlLib] Remove duplicates when building coverage 2021-11-06 13:32:43 -04:00
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