91 Commits

Author SHA1 Message Date
Behdad Esfahbod
f5e62a1375 [varLib.optimize] Minor more idiomatic 2023-05-25 10:54:13 -06:00
Behdad Esfahbod
dbc91b1b5b [varStore.optimize] Remove unused variable 2023-05-25 08:52:13 -06:00
Behdad Esfahbod
12aba9070f [varStore.optimize] Combine a couple of loops 2023-05-25 08:50:01 -06:00
Behdad Esfahbod
b0a0f74492 [varStore.optimize] Speed up some more 2023-05-25 08:47:47 -06:00
Behdad Esfahbod
b6ebb4c411 [varStore.optimize] Further speedup 2023-05-25 08:45:53 -06:00
Behdad Esfahbod
d8fabfa362 [varStore.optimize] Remove unused method 2023-05-25 08:28:12 -06:00
Behdad Esfahbod
832f2f766f [varStore.optimize] Use faster intTools.bit_count as popcount 2023-05-25 08:19:15 -06:00
Behdad Esfahbod
9cbde09cdc [varStore.optimize] Speed up 2023-05-25 08:09:27 -06:00
Behdad Esfahbod
f12f3d863c [varStore.optimize] Remove unused best_new_encoding 2023-05-25 07:56:33 -06:00
Behdad Esfahbod
da305615d0 [varStore.optimize] Simplify algorithm
Produces better results even.
2023-05-25 07:49:13 -06:00
Behdad Esfahbod
47ec18f788 [varStore] Better optimize() algorithm
See comments.

Produces better results.
2023-05-25 07:39:41 -06:00
Behdad Esfahbod
93d87df315 [varStore] Refactor code into a method 2023-05-25 07:12:27 -06:00
Behdad Esfahbod
035529883c [varStore] Minor rename a method 2023-05-25 07:06:48 -06:00
Behdad Esfahbod
c1ab8995f2 [varStore] Minor adjustment to the optimize() algorithm
It's very unlikely that this path is needed, but it's correct
to have it.
2023-05-25 07:00:28 -06:00
Behdad Esfahbod
a08f5ebbc9 [varStore] Update comment 2023-05-25 06:24:00 -06:00
Behdad Esfahbod
ae7394e68a [varLib.main] Accept --quantization 2023-05-24 18:10:08 -06:00
Behdad Esfahbod
d9649a7835 [varStore] Add test for quantization 2023-05-24 18:10:08 -06:00
Behdad Esfahbod
311bda2021 [varStore] Add optional quantization to optimize() 2023-05-24 18:10:08 -06:00
Behdad Esfahbod
47813b217c [varStore] Make optimize() stable
Before, calling optimize() on its own output could generate different
result. I think it's stable now.
2023-05-24 18:09:58 -06:00
Behdad Esfahbod
6b20edf1fb [varStore] Fix algorithm comment to match code 2023-05-24 17:08:20 -06:00
Behdad Esfahbod
1aa088e150 [varStore.main] Speed up if output is not requested 2023-05-24 17:05:00 -06:00
Behdad Esfahbod
2f78605c27 [varStore] Change a sort key in optimize()
Produces more optimized results in empirical testing.
2023-05-24 16:55:16 -06:00
Behdad Esfahbod
aeaf98a438 [varStore] Another fix and test 2023-05-24 16:34:15 -06:00
Behdad Esfahbod
8ae33a7ef3 [varStore] Add a round=round parameter to storeMasters 2023-05-24 14:24:36 -06:00
Behdad Esfahbod
b72a8da045 [varStore] Adjust encoding overhead in optimize()
Previously we were not accounting for the LOffset to VarData.
2023-05-24 13:21:33 -06:00
Behdad Esfahbod
0677c0e705 [varStore] Another bugfix in optimize() 2023-05-24 13:18:58 -06:00
Behdad Esfahbod
cb2f5aacd3 [varStore] More documentation 2023-05-24 12:19:46 -06:00
Behdad Esfahbod
cdcbf64d36 [varStore] Document the optimize algorithm 2023-05-24 12:09:43 -06:00
Behdad Esfahbod
58954179ec [varStore] Another fix to the optimize algorithm
Previously we were disregarding the best_gain. Ouch!
2023-05-24 12:02:05 -06:00
Behdad Esfahbod
6097b3293b [varStore] Improve optimize algorithm
This was always supposed to be how it works, but was missed in
the initial implementation apparently.
2023-05-24 11:07:19 -06:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Cosimo Lupo
a08140dc76 [varStore/subset] correctly handle NO_VARIATION_INDEX when subsetting varidxes
otherwise GDEF/GPOS.remap_device_varidxes may fail with KeyError attempting to map a NO_VARIATION_INDEX
2022-07-06 17:29:00 +01:00
Cosimo Lupo
7ab7940761 varLib: simplify a bit following varStore.py recent changes
#2662
2022-06-24 10:20:48 +01:00
Behdad Esfahbod
e01f643a8e [varLib.varStore] Support NO_VARIATION_INDEX in optimizer & instancer
Fixes https://github.com/fonttools/fonttools/issues/2211
2022-06-23 12:01:20 -06:00
Behdad Esfahbod
cac7241514 [varLib.varStore] Add NO_VARIATION_INDEX
Part of https://github.com/fonttools/fonttools/issues/2211
2022-06-23 12:01:20 -06:00
Behdad Esfahbod
e917c43ca9 [varLib.varStore] Add operator __bool__ and use it
Part of https://github.com/fonttools/fonttools/issues/2211#issuecomment-790125437
2022-06-21 14:03:20 -06: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
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
07a7dd3eb5 [varLib] Make newly-added round arguments keyword-only
So they are not accidentally set, only intentionally. Keeps positional-args
open for more direct uses.
2021-03-04 09:44:34 -07:00
Behdad Esfahbod
f5ef0b517b [varLib] Round most deltas using bankers' round, not otRound
See https://github.com/fonttools/fonttools/pull/2214#issuecomment-790742479
2021-03-04 09:43:26 -07:00
Behdad Esfahbod
68004b8fec [varLib] Shift most (all?) delta-rounding to VarModel
Reduces error.

The main varfont-builder now asks the model to do rounding, and asks
VariationStore to do no rounding, so we don't spend extra times rounding
multiple times (specially with the heavy otRound).

I *think* I got it all and right...

Fixes https://github.com/fonttools/fonttools/issues/2213
2021-03-04 09:20:43 -07:00
justvanrossum
16e058fe97 Test for 0xFFFF, not 0xFFF, fixes #2073 2020-10-09 09:33:47 +02:00
Simon Cozens
089f24da6b
Ensure all fonttools CLI tools have help documentation (#1948)
Note UI change : `fonttools varLib.models` now takes prefixed options `-d` or `-l` instead of guessing the intended feature from the number of arguments.

We have a number of command line tools which are somewhat opaque. (varLib.models in particular was very confusing.) This ensures that they all use argparse to have a consistent interface, and all have --help documentation which at least details their parameters, and hopefully therefore gives more of a clue about what they do. Those which use logging have had a command-line logging parameter added.
2020-05-12 15:11:30 +01:00
Simon Cozens
2cef07af80
[doc] Add help options to fonttools CLI (#1920)
This adds a `help` verb (and `--help` option) to the `fonttools` command line tool. Submodules will be listed in the help text if they have an importable `main` function with a docstring, and `main`'s docstring will be used as the one-line description for the help text.
2020-05-12 06:31:13 +01:00
Nikolaus Waxweiler
68a5ceac6d varLib: Remove py23 imports 2019-08-10 15:39:02 +01:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Cosimo Lupo
f74e82fec5
Merge remote-tracking branch 'origin/master' into partial-instancer 2019-04-29 12:47:37 +02:00
Michiharu Ariza
00dddb1c32 fixed non retain-gids with no AdvWidthMap behavior
deltas in VarData[0] are directly look up by GID so compacted
if any deltas are referenced by LsbMap / RsbMap but not used for advance widths, they are moved to the end of VarData[0]

updated expected test result expect_HVVAR.ttx accordingly
2019-04-24 16:46:21 -07:00
Michiharu Ariza
6ca384fecd tweaks reflecting review 2019-04-24 09:26:17 -07:00