150 Commits

Author SHA1 Message Date
Cosimo Lupo
97929b3236
[feaLib] try reuse existing inline chained multiple subst lookups when possible
We already do this for inline single substitutions in chained contextual lookups, this PR extends this for multiple substitutions as well.

Fixes https://github.com/fonttools/fonttools/issues/3551
2024-06-03 17:06:46 +01:00
خالد حسني (Khaled Hosny)
90e391bb31
Update Lib/fontTools/otlLib/builder.py
Co-authored-by: Cosimo Lupo <cosimo@anthrotype.com>
2024-02-15 14:56:10 +02:00
Khaled Hosny
bb557938bd [otlLib] Document buildMathTable 2024-02-14 02:54:15 +02:00
Khaled Hosny
0f953cccd8 [otlLib] Support building MATH table 2024-02-14 02:48:13 +02:00
Cosimo Lupo
3975ce6339
avoid calling getCompiledSize_ twice 2024-02-06 12:25:00 +00:00
Cosimo Lupo
96054e8152
[otlLib] choose most compact contextual lookup format (#3439)
* [otlLib] chose most compact contextual lookup format

Fixes https://github.com/fonttools/fonttools/issues/2934
2024-02-05 16:59:29 +00:00
Cosimo Lupo
6ff7d00e06
[feaLib] fix ordering of alternates in aalt lookups
Fixes https://github.com/fonttools/fonttools/issues/2937
2024-01-25 13:25:41 +00:00
Cosimo Lupo
f96b2128a1
[feaLib] keep declaration order of ligatures within ligature set
Fixes #3428
2024-01-24 12:59:00 +00:00
Khaled Hosny
c65dba41bb [otlLib] Pass ttFont to name.addName in buildStatTable
Avoids ltag warning similar to:
ae31d056051a28c39bc60fa2b827bc14efcef287
2024-01-07 14:37:53 +02: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
Simon Cozens
c5295d2f16
Better OTL builder errors (#3286)
* Raise a sensible error for keyerror

* Try harder to find error locations

* Chain exception
2023-10-05 11:09:22 +01:00
خالد حسني (Khaled Hosny)
9ad4a36309
Merge pull request #3130 from fonttools/fealib-ligcaret-variable
[feaLib] Support variable ligature caret position
2023-06-08 14:58:23 +03:00
Khaled Hosny
a43f824af9 [feaLib] Support variable ligature caret position
Allow variable scaler in ligature caret position and build
CaretValueFormat3 with DeviceTable. Does not support non-variable device
table, but can be added if someone really really wants it.
2023-05-30 20:21:21 +03:00
David Corbett
b8dcb85161 [otlLib] Fix error message in MarkBasePosBuilder 2023-05-28 20:29:49 +02:00
Khaled Hosny
fd6c81585f [otlib] Add a config option to write GPOS 7 lookups
See the inline comment and option documentation
2023-03-13 16:34:33 +02:00
Khaled Hosny
253b4f9afc [feaLib] Further merge inline single substitutions
Fixes https://github.com/fonttools/fonttools/issues/2150 (see the
discussion there).
2023-01-28 09:51:49 -07:00
Cosimo Lupo
41ff9511cc
otlLib: sort names after building STAT, set AxisValueCount=0 2022-10-20 16:44:02 +01:00
Simon Cozens
64fd837ca1
Allow multiple value record types in the same pairpos table (#2776)
* Use buildPairPosClassesSubtable's ability to promote value records (see #2772)

* Add tests for #2772
2022-09-05 14:44:50 +01:00
Cosimo Lupo
20de0784c2 send DeprecationWarning if FONTTOOLS_GPOS_COMPACT_MODE env var is set
and factor out shared code to read the env var
2022-04-22 11:32:43 +01:00
Jany Belluz
0bd2834d1e Fix ufo2ft regression by bringing back the env var for now 2022-04-22 10:14:16 +01:00
Jany Belluz
abc0441957 [config] Add new config module and use it for GPOS compression level 2022-04-14 15:23:02 +01:00
Simon Cozens
2d62a2ac9e
Disable GSUB5 optimization (#2540)
* Disable GSUB5/GPOS7 optimization

* Revert "Fixup test expectations"

This reverts commit 7db13c9872884772312727e3478fb36ed9883004.

* Revert "Rename GPOS8->GPOS7"

This reverts commit 6d4c5fe31c9199e6d3e46cd0808e7640d1610e75.

* Revert "Fix varlib test expectations - now badly named."

This reverts commit 4adea942cc73b6afe58e00278da6cb3795935970.

* Allow GSUB5, disable GPOS7

* Revert "Revert "Fixup test expectations""

This reverts commit 42993ae6917f8f6e4c31f4be123caca24d27d2da.

* Fix up expectations
2022-04-08 15:54:34 +01:00
Olli Meier
cf6d25cc9e As recommended from anthrotype I did: $ black Lib/fontTools/otlLib/builder.py 2022-02-11 15:55:01 +01:00
Olli Meier
68fa3bbd47 Cleaning code based on feedback from Just 2022-02-10 22:13:58 +01:00
Olli Meier
d77ec968a3
Update Lib/fontTools/otlLib/builder.py
Co-authored-by: Just van Rossum <justvanrossum@gmail.com>
2022-02-10 22:00:18 +01:00
Olli Meier
459f18ab4a
Update Lib/fontTools/otlLib/builder.py
Co-authored-by: Just van Rossum <justvanrossum@gmail.com>
2022-02-10 21:59:48 +01:00
Olli Meier
d5406feed7
Update Lib/fontTools/otlLib/builder.py
Co-authored-by: Just van Rossum <justvanrossum@gmail.com>
2022-02-10 21:59:09 +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
512d1a219c cleaning code. 2022-02-10 15:16:28 +01:00
Olli Meier
7f21d5eee3 adding variable platforms 2022-02-10 15:14:20 +01:00
Olli Meier
2a4b4a594a based on feedback, another idea 'force' 2022-02-10 14:24:41 +01:00
Olli Meier
42b272e5d9 fix failing unitest. Look and create only names about name IDn 255 (Private Use Area) 2022-02-10 14:01:04 +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
Simon Cozens
0f03e6529a
[docs] Fix sphinx warnings (#2453)
* Add default auto doc options

* Ensure all references are unique

* Use anonymous links to avoid duplicate references

* Remove default options, fix wrong module name

* Don’t index repeated class

* Remove repeated classes included through automodule

* Fix warnings

* We don’t use our own static directory

* Correctly format XML in docs

* Fix indentation

* Fix overline

* Bring TOC to top

* Fix definition list

* Offset definition lists and examples

* Fix erroneous markup

* Fix markup

* Already included in automodule

* Fix args markup

* Correct markup for example

* Don’t reindex repeated module

* Correct XML code block markup

* Fix markup errors, change example to doctest

* Correct list markup

* Make ttx docstring both valid RST and valid help output

* Various other boring markup fixes

* Fix example indenting

* Make docstring valid RST and valid help output

* Mock import for reportlab

* It’s ok if manual links don’t appear in toctrees

* Oops typo, I guess doctests are useful
2021-12-02 15:31:49 +00:00
David Corbett
cfa69f245f [otlLib] Remove duplicates when building coverage 2021-11-06 13:32:43 -04:00
Simon Cozens
563730f8ce
Support variable feature syntax (#2432) 2021-10-28 11:58:54 +01:00
Simon Cozens
ed833dab74 Don’t complain about format 1 lookups we couldn’t even build 2021-09-20 10:34:41 +01:00
Simon Cozens
f53a75fb1d Check for overflows in a loop 2021-09-15 11:08:50 +01:00
Simon Cozens
f9b927cdbb Fix chained contextual builder overflow 2021-08-30 10:35:56 +01:00
Jany Belluz
604513a38f Fix a few comments 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
Nikolaus Waxweiler
2089d05126
Merge pull request #2229 from fonttools/varLib-otlLib-noreload
[varLib/otlLib] Allow merging into VariationFont without first saving GPOS PairPos2
2021-03-22 16:42:45 +00:00
Behdad Esfahbod
0faf01d5f1 [otlLib] Generate Value1 / Value2 if respective formats are non-zero
Previously otlLib was generating None if the values themselves were
empty even if the value format was non-empty.  This happened to work
for compiling to binary since the compiler handles Value=None.

But this was confusing varLib.merger module (as in when building
variable fonts from such otlLib-built master GSUB/GPOS tables, without
roundtripping to OTF/TTF binary first), because in varLib.merger,
a None means "this master doesn't provide that info; skip it"; whereas
in a PairPos table a None as generated by otlLib simply meant "all
values are zero", which is different from "this master doesn't
provide this value".

This fixes that, such that ufo2ft can build variable-font without
saving masters to binary.

Part of https://github.com/googlefonts/ufo2ft/pull/486
2021-03-19 13:59:27 -06:00
Simon Cozens
f2f8a6a42a Fix docstring too 2021-03-15 13:47:44 +00:00
Simon Cozens
d0101eff1e Correct otlLib documentation 2021-03-15 11:34:36 +00:00
Cosimo Lupo
9aeb48286d
black 2021-02-25 17:16:02 +00:00