46 Commits

Author SHA1 Message Date
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
Behdad Esfahbod
2ca6cc2dc3 [varLib] Handle overflow in OnlineVarStoreBuilder 2018-02-19 16:42:51 -08:00
Behdad Esfahbod
3cfc4a4be2 [subset] Move code around 2018-02-18 23:16:00 -08:00
Behdad Esfahbod
f3def2ea5a [subset] Fix pruning of GDEF VarStore 2018-02-18 22:37:44 -08:00
Behdad Esfahbod
e0f2848ef5 [subset] Subset Regions when subsetting VarStore
Part of https://github.com/fonttools/fonttools/issues/1179
2018-02-18 19:45:57 -08:00
Behdad Esfahbod
67814fd3b3 [subset] Prune GDEF VarStore
Mostly fixes https://github.com/fonttools/fonttools/issues/1179
2018-02-18 19:20:00 -08:00
Cosimo Lupo
28bb992c1f replace int(round(...)) with round(...)
We don't need to cast to int when using the round function from py23,
as this is a backport of python3's built-in round and thus it returns
an int when called with a single argument.
2017-10-22 12:03:52 +01:00
Behdad Esfahbod
5eb3cbe2b0 [varLib.mutator] Mutate GPOS
Cleans up GDEF varstore as well.

What's left:

- In none of the varLib.merger Mergers we handle the CaretValueFormat3. That should be done,
  even though no one uses this,

- GPOS/GSUB FeatureVariations are not applied.  Shouldn't be hard.

- 'rvrn' should be folded into 'ccmp' or some other default feature.
2017-10-20 20:13:14 -04:00
Behdad Esfahbod
e05ece2715 [varLib.varStore] Cache scalars in VarStoreInstancer 2017-10-20 20:13:14 -04:00
Behdad Esfahbod
7494943c1b [varLib.varStore] Add VarStoreInstancer 2017-10-20 20:13:14 -04:00
Behdad Esfahbod
8db7a65d39 [varLib.varStore] New module 2017-10-20 20:13:14 -04:00