60 Commits

Author SHA1 Message Date
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
Michiharu Ariza
12d1b053f7 renaming 2019-04-23 09:28:03 -07:00
Michiharu Ariza
5e1dea329b subset HVAR/VVAR with retain-gids
1. if AdvWidthMap/AdvHeightMap missing, deltas for unused (emptied) glyphs are zeroed
2. If indexMap exists and unused glyph ID <= last used glyph ID, then its major/minor number set to 0/0
3. If indexMap exists and unused glyph ID > last used glyph ID, then its major/minor number set to that of the last used glyph (removed from table)
2019-04-22 16:56:01 -07:00
Cosimo Lupo
8aa57fef81
instancer: convert item to tuple varstore to reuse same partial istancing code 2019-04-18 10:17:54 +01:00
Behdad Esfahbod
361e1e6aa0
Merge pull request #1377 from fonttools/varlib-interpolate-cff2
Varlib interpolate cff2
2018-11-30 00:21:13 -05:00
Behdad Esfahbod
abb9d149ed [subset] Fix subsetting of VarStore
Was *so* broken.  Ouch!

Reported by Nyshadh, reproduced with Comfortaa-Regular.ttf.
2018-11-20 00:24:28 -05:00
ReadRoberts
617b8c6396 [varLib.mutator] Interpolating CFF2 tables. Make more fixes per recommendations
varStore.py. Commit the correct function references.
psCharstrings.py. Add decompiler class specifically for flattening subroutinized charstrings.
mutator.py. Flatten the subroutinized charstrings, delete the Subrs.
TestCFF2VF.otf, Updated to version with subroutinization. Updated expected ttx output.
2018-11-19 20:08:00 -08:00
ReadRoberts
fddd5b2bae [varLib.mutator] Interpolating CFF2 tables. Makes fixes per recommendations
varLib.py. restore import of 'fontTools.misc.py23 import *'
varStore.py. Rename 'applyScalar' to 'interpolateFromDeltasAndScalars', and refactor common code with __git__item to a static method.
mutator.py. Update to reflect function name change to interpolateFromDeltasAndScalars. Changed some logic from one line to several lines for readability, and i to avoid flake8 warnings about line too long.
2018-11-19 20:06:16 -08:00
ReadRoberts
d43ebd5e49 [varLib.mutator] Add support for interpolating CFF2 tables
Add handling of CFF2 table to mutator.py

Add public method applyScalars() to varStore.py::VarStoreInstancer()
2018-11-19 20:06:03 -08:00
Behdad Esfahbod
02f3512fb1 [varLib.varStore] Minor 2018-11-19 16:15:45 -05:00
Behdad Esfahbod
252059b6b8 [varLib.varStore] Simplify 2018-11-19 15:49:14 -05:00
Behdad Esfahbod
0d85fc57d0 [varLib] Fix recursing object tree in varStore
Was barfing on Coverage objects if they didn't have .Format.  Ouch!
2018-11-09 00:00:33 -05:00
Behdad Esfahbod
c2f0cdc31b [varLib] Fixups
Sorry that this is a mixed bag.

Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 16:39:11 -05:00
Behdad Esfahbod
f52661da77 [varLib] Fixup 2018-11-08 14:39:15 -05:00
Behdad Esfahbod
bc7f5ee73f [varLib] Minor
Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 14:36:40 -05:00
Behdad Esfahbod
84580fee64 [varLib] Add VarData_add_item()
Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 14:24:24 -05:00
Behdad Esfahbod
b252f0272f [varLib] Add setSupports() and storeDeltas() to OnlineVarStoreBuilder
Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 14:05:51 -05:00
Behdad Esfahbod
611e4d4044 [varLib] Allow changing model in OnlineVarStoreBuilder
Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 13:56:31 -05:00
Cosimo Lupo
d570fc038a
use otRound when rounding visual coordinates or deltas
So we now round towards +Infinity in:

- floatToFixed (which fully examplify that quotes from OT spec)
- psCharStrings: when packing floats as fixed 16.16
- t2CharStringPen: when rounding coordinates and advance widths
- subset: when rounding advance widths to compute average
- TupleVariation: rounding gvar deltas
- _g_l_y_f: when rounding coordinates: both in GlyphComponent.{x,y}
  and for GlyphCoordinates.toInt()
- _h_m_t_x: for rounding horiz/vert metrics
- varLib: rounding horiz metrics and deltas
2018-06-14 17:40:11 +01:00
Behdad Esfahbod
1917d6913b [subset] Remove more nonsensical code
Remaining parts of 4e3192163470ca168ff753cb526480e59bc77e1a
2018-04-25 16:09:30 -07:00
Behdad Esfahbod
03b9c50055 [varLib] Don't remap same DeviceTable twice
The variation merger reuses matrix rows / entries when aligning kerning
matrices.  Don't remap same DeviceTable twice.  Alternative fix would
have been to not reuse objects but that slows things down.

Fixes https://github.com/fonttools/fonttools/issues/1206
2018-03-06 17:59:27 +01:00
Behdad Esfahbod
54fd71f73c [varLib/subset] Fix subsetting of GPOS variation data
Was not picking up ValueRecord Device objects. Ouch!
2018-02-27 18:52:07 -08:00
Behdad Esfahbod
e299650f9f [varStore] In OnlikeVarStoreBuilder, dedup items
While we optimize VarStore later, just deduping here reduces amount
of data we have to work with later by 8x in NotoSans-VF.ttf test
case.  It's a cheap optimization, so do it.
2018-02-21 15:12:20 -08:00
Cosimo Lupo
767b9311eb
[varStore] don't import unicode_literals
Tests were failing on python 2.7.6 because array module doesn't accept
unicode strings (fixed in later 2.7.x releases).

An alternative fix would have been to cast array(str('h'), [...]) but
that seemed a bit too much, especially since varStore module doesn't
really do heavy text manipulation (there aren't other string literals).

We cannot use unicode_literals unconditionally, because of this and
similar issues in the stdlib. We should use it only when it makes sense
and reduces the frequency of u"".
2018-02-21 12:11:59 +00:00
Behdad Esfahbod
d46d40dc9e [varLib] Actually remove duplicates while optimizing VarStore!
Ouch!  Shrinks NotoSans-VF.ttf GDEF VarStore further down.
Original was 1016278 bytes. Before this change it was optimizing
to 256145 bytes. With this change, it goes down to a mere 57127
bytes!!!
2018-02-21 01:27:58 -08:00
Behdad Esfahbod
e910309952 [varLib] Optimize HVAR VarStore and indirection 2018-02-21 01:22:59 -08:00
Behdad Esfahbod
1adf7fd2c0 [varLib] Update tests for VarStore optimization
Also, don't emit GDEF if VarStore is empty.
2018-02-21 01:10:36 -08:00
Behdad Esfahbod
4e31921634 [varLib] Remove nonsensical code
GSUB has no positioning, so cannot have any Device tables with variations.
2018-02-21 00:19:54 -08:00
Behdad Esfahbod
3c4203d985 [varLib.varStore] Implement VarStore optimizer
On NotoSans-VF.ttf (a 5MB font), saves 15% total size by optimizing
GDEF VarStore and resulting GPOS shrinkage.
2018-02-21 00:18:55 -08:00
Behdad Esfahbod
073227bbb0 [varLib.varStore] Start implementing a VarStore optimizer
Commandline takes varfont and optimizes its GDEF VarStore.
2018-02-20 20:58:18 -08:00
Behdad Esfahbod
ba52a32fed [varStore] Refactor code around 2018-02-19 19:07:22 -08:00
Behdad Esfahbod
64834d079d [varStore] Add subset_varidxes as method on VarStore 2018-02-19 18:57:09 -08:00