858 Commits

Author SHA1 Message Date
Khaled Hosny
232b2ccbc4 Move the rest of py23 module to textTools
Change all imports to use textTools module, except the test_py23.py test
which is kept until we decide to remove the module (if ever).
2021-08-20 01:29:45 +02:00
Cosimo Lupo
971043374e instancer: add --ignore-overlap-errors option
This is to be able to ignore tricky glyphs that sometimes trip up Skia PathOps.Simplify operation.
We have no idea how to fix this upstream (short of having the glyphs redrawn), and perfect is the enemy of good..
2021-07-29 16:59:04 +02:00
Cosimo Lupo
40897a1508 Define DeltaSetIndexMap table used for COLR.VarIndexMap
https://github.com/googlefonts/colr-gradients-spec/pull/316
2021-07-23 17:27:57 +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
Cosimo Lupo
b8ce99962c [merger] make getattr(valueRecord, *) default to 0 if it has Device tables but corresponding value is not set
Fixes https://github.com/fonttools/fonttools/pull/2323
2021-05-25 12:36:17 +01:00
Cosimo Lupo
465c327b5f
Merge pull request #2300 from fonttools/fix-varlib-merger-errors
VarLibMergeError first parameter must be a Merger object
2021-05-13 15:48:58 +01:00
Cosimo Lupo
72004fcd7e VarLibMergeError first parameter must be a Merger object
a lot of places instead pass in the 'self' parameter, incorrectly assuming that is a Merger.
This is meant to fix 'AttributeError: 'dict' object has no attribute 'ttfs'' as reported in https://github.com/googlefonts/fontmake/issues/766#issuecomment-836576341
2021-05-13 15:40:44 +01:00
Simon Cozens
b41b062402 We are iterating over supports, not locations, here 2021-05-12 16:13:58 +01:00
Simon Cozens
2aa1a6ddf6 Remove else-after-return 2021-05-12 15:04:41 +01:00
Simon Cozens
5ac809410f Reformat with black 2021-05-12 15:02:59 +01:00
Simon Cozens
1526b9e024 Another unused enumeration 2021-05-12 15:01:18 +01:00
Simon Cozens
f711b65475 Index was never used 2021-05-12 14:57:20 +01:00
Simon Cozens
1c509f931d Avoid unnecessary intermediary variables 2021-05-12 14:56:44 +01:00
Simon Cozens
ab328b5ecc axisPoints is not used outside the sort function 2021-05-12 14:55:14 +01:00
Just van Rossum
31ab3aae0b
Merge pull request #2285 from fonttools/varStore-32bit
Improve otBase facilities / towards 32bit VariationStore
2021-05-08 17:10:17 +02:00
Behdad Esfahbod
03e97edf14 [varLib.varStore] Use binary notation for bit constants
https://github.com/fonttools/fonttools/pull/2285#discussion_r625708297
2021-05-07 15:45:55 -06:00
Behdad Esfahbod
98e2bf5526 [varLib.builder] Document bit-tweedling
https://github.com/fonttools/fonttools/pull/2285#discussion_r628401241
2021-05-07 15:41:33 -06:00
Cosimo Lupo
6b9b23251e VarLibMergeError.stack is a list of str, not a str
Fixes https://github.com/googlefonts/fontmake/issues/766
2021-05-06 11:59:10 +01:00
Khaled Hosny
a1c6c184ef [mutator] Round lsb for CFF2 fonts as well
Otherwise head table compilation would fail because of the floating
point side bearing. The advance width is already rounded.
2021-05-03 00:06:46 +02:00
Behdad Esfahbod
0549b27afb [varLib.varStore] Implement 32bit VarStore optimization
This concludes https://github.com/fonttools/fonttools/issues/2279

Part of https://github.com/fonttools/fonttools/pull/2285
2021-05-01 15:12:08 -06:00
Behdad Esfahbod
9350166792 [varLib.varStore] Remove use of array.array 2021-05-01 15:04:51 -06:00
Behdad Esfahbod
e454e96238 [varLib.builder] Implement building 32bit VarStore
The full optimizer in varLib.varStore still needs to be updated.
But this pretty much enables building 32bit VarStores, even if they
won't be fully optimal.

Part of https://github.com/fonttools/fonttools/issues/2279
2021-05-01 14:27:11 -06:00
Chris Simpkins
8a63c06b8b [varLib.instancer] update instantiateVariableFont docs
updated to indicate that Level 3 sub-space ranges are supported, but you must include the default axis value in the new range
2021-05-01 12:04:13 -06:00
Behdad Esfahbod
f514a6823d [varLib.merger] Use Value.getEffectiveFormat() instead of .getFormat() 2021-04-22 12:29:16 -06:00
Behdad Esfahbod
438dcb5a7f
Update Lib/fontTools/varLib/instancer/__init__.py
Co-authored-by: Nikolaus Waxweiler <madigens@gmail.com>
2021-04-14 21:04:48 -06:00
Behdad Esfahbod
a43690ef5b [varLib.instancer] Add back instantiateGvarGlyph() 2021-04-14 14:43:24 -06:00
Behdad Esfahbod
a756bb01ab [glyf] Prefix setCoordinates, getCoordinatesAndControls, getPhantomPoints
Will add old name with old API next.
2021-04-14 14:09:40 -06:00
Behdad Esfahbod
6aa9d192b6 [varLib] Use TTFont.get() in a couple of places 2021-04-14 13:50:00 -06:00
Behdad Esfahbod
15c34e9ba9 [glyf] Add .get() which is like __getitem__() but returning None if not found
And use it in a couple places.
2021-04-13 15:06:25 -06:00
Behdad Esfahbod
f80e19da35 [varLib] Minor optimizations in maxp and TThinting 2021-04-13 15:03:42 -06:00
Behdad Esfahbod
f387620572 [varLib] Reduce TTFont.__getitem__() in _merge_TTHinting 2021-04-13 14:49:50 -06:00
Behdad Esfahbod
34b5ff623c [varLib] Optimize getPhantomPoints()
To reduce calling TTFont.__getitem__ many times per glyph!
2021-04-13 13:49:12 -06:00
Behdad Esfahbod
ee5ecd19d7 [varLib/glyf] Remove fallback vertical phantom-points code
I suggested Cosimo add that code in
https://github.com/fonttools/fonttools/pull/1528

Upon further inspection now, that code is unnecessary and even wrong in
cases where different masters have different ascent, because that would
result in encoding variations for vertical phantom points, which will
be then either be unused or double-apply on top of ascent etc.
2021-04-12 18:28:01 -06:00
Behdad Esfahbod
ef0d695de9 [TupleVariation] Remove unused usesSharedPoints return from tv.compile() 2021-04-09 12:13:49 -06:00
Behdad Esfahbod
416ff89171 [TupleVariation] Minor optimize in using sharedCoordinates 2021-04-08 11:40:44 -06:00
Behdad Esfahbod
96690de9a9 [varLib] Optimize out multiplication by 1 when computing deltas 2021-04-08 09:41:45 -06:00
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
2021-03-29 11:45:58 +02:00
Behdad Esfahbod
3d578dd1de [varLib.merger] Adjust for removal of Coverage / ClassDef .Format 2021-03-23 11:05:00 -07:00
Behdad Esfahbod
69918d2945 Revert "[varLib.merge] Fix tests"
This reverts commit fb0c60cd2ce68df546ea2887946bc7f97bbb6921.
2021-03-23 11:02:41 -07:00
Simon Cozens
baf6c5d1e1 Remove pass if we have a docstring 2021-03-19 10:48:58 +00:00
Simon Cozens
5d7c826b0b Make CFF merge errors inherit differently 2021-03-19 10:40:02 +00:00
Simon Cozens
bfe4bad37b Use kwargs and explicit stack 2021-03-19 10:38:15 +00:00
Simon Cozens
8ba31b0a43 Improve error message 2021-03-18 21:23:40 +00:00
Simon Cozens
956087eb81 super doesn’t magically call its own methods 2021-03-18 21:23:34 +00:00
Simon Cozens
3e0a87a146 Shorten exception names 2021-03-18 20:58:11 +00:00
Simon Cozens
6c547864b6 Use individual exception classes instead of enum 2021-03-18 15:49:49 +00:00
Simon Cozens
02ebcf8077 Redundant computation 2021-03-17 14:59:36 +00:00
Simon Cozens
bfc4ac9524 Compare enums by identity 2021-03-17 14:59:11 +00:00
Simon Cozens
b26728d3cb Specifically catch VarLibMergeError 2021-03-17 11:56:02 +00:00