144 Commits

Author SHA1 Message Date
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
2ff3159a5f Mark the environment variable as experimental 2021-07-05 17:28:44 +01:00
Jany Belluz
527179619b Refactor the Cluster class to be top-level instead of nested the function 2021-07-05 17:28:44 +01:00
Jany Belluz
d1c46f9d10 Clarify comment with the plan vs the actual implementation 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
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
Kamile Demir
29ff42d15f
Reusing otlLib buildStatTable() in feaLib 2021-02-25 17:16:02 +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
Martin Hosken
ee87790326 Refix by removing duplicates from the same glyphset 2020-12-01 23:55:43 +07:00
Martin Hosken
75f314b149 Fix class2defs self overlapping glyphsets 2020-12-01 23:38:12 +07:00
Simon Cozens
fb9d34af1b Try again... 2020-11-17 12:05:52 +00:00
Simon Cozens
df5527bccc Revert "Remove unneeded populateDefaults". removed wrong line...
This reverts commit a043e35f1ca287431bd63aa566d50d7e70634fea.
2020-11-17 12:05:31 +00:00
Simon Cozens
635df38f32 Comment to explain copy 2020-11-17 09:13:30 +00:00
Simon Cozens
8e524e41f5 "if not x in" -> "if x not in" 2020-11-17 09:12:38 +00:00
Simon Cozens
7bbff5d21f Re-case variable names (and clarify) 2020-11-17 09:11:56 +00:00
Simon Cozens
1a6f53dfc9 Explain weird (list(foo))[0] thing 2020-11-17 09:11:37 +00:00
Simon Cozens
a043e35f1c Remove unneeded populateDefaults 2020-11-17 09:08:44 +00:00
Simon Cozens
be7d9a33a3 Raise on unknown format, also reorder to be more sensible 2020-11-17 09:08:20 +00:00
Simon Cozens
07b186a41e Build most compact lookup representation
This builds all possible representations of a contextual lookup and then selects the most copact
2020-11-16 13:42:07 +00:00
Simon Cozens
f6fac3cbbf Helper function to determine compiled size of a lookup 2020-11-16 13:41:19 +00:00
Simon Cozens
ef002fbcc3 Add format 1 subtable builder 2020-11-16 13:41:02 +00:00
Simon Cozens
8b3963a306 Add format 2 subtable builder 2020-11-16 13:40:50 +00:00