ReadRoberts
4da8f43eeb
[varLib] Fix bug in varLib.build() for CFF2.
...
The logic should attempt to build a cvar table only if there is a glyf table. This stack dumps when the font is a CFF2 font.
2018-05-10 10:12:28 +01:00
Behdad Esfahbod
0ecf5c5c94
[varLib.models] Refine modeling one last time
...
In a523a697164a4 I changed the model such that when computing master
supports and we hit another master, cut the box in one dimension only,
to avoid interferring with other master. The axis to cut against was
chosen as axis that minimizes volume loss. That was fine in a sense,
but missed a great amount of information resulting from relative
positioning of the two masters. As such, it could not distinguish
between the following two situations:
behdad:fonttools 0 (master*)$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .5,.5 .55,.75
Sorted locations:
[{},
{'A': 1.0},
{'B': 1.0},
{'A': 1.0, 'B': 1.0},
{'A': 0.5, 'B': 0.5},
{'A': 0.55, 'B': 0.75}]
Supports:
[{},
{'A': (0, 1.0, 1.0)},
{'B': (0, 1.0, 1.0)},
{'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0, 0.55, 1.0), 'B': (0.5, 0.75, 1.0)}]
behdad:fonttools 0 (02616ab...)$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .5,.5 .75,.55
Sorted locations:
[{},
{'A': 1.0},
{'B': 1.0},
{'A': 1.0, 'B': 1.0},
{'A': 0.5, 'B': 0.5},
{'A': 0.75, 'B': 0.55}]
Supports:
[{},
{'A': (0, 1.0, 1.0)},
{'B': (0, 1.0, 1.0)},
{'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0, 0.75, 1.0), 'B': (0.5, 0.55, 1.0)}]
Check the last line. In both cases the box was cut against the second axis.
After this change, we get:
behdad:fonttools 0 (master)$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .5,.5 .55,.75
Sorted locations:
[{},
{'A': 1.0},
{'B': 1.0},
{'A': 1.0, 'B': 1.0},
{'A': 0.5, 'B': 0.5},
{'A': 0.55, 'B': 0.75}]
Supports:
[{},
{'A': (0, 1.0, 1.0)},
{'B': (0, 1.0, 1.0)},
{'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0, 0.55, 1.0), 'B': (0.5, 0.75, 1.0)}]
behdad:fonttools 0 (master)$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .5,.5 .75,.55
Sorted locations:
[{},
{'A': 1.0},
{'B': 1.0},
{'A': 1.0, 'B': 1.0},
{'A': 0.5, 'B': 0.5},
{'A': 0.75, 'B': 0.55}]
Supports:
[{},
{'A': (0, 1.0, 1.0)},
{'B': (0, 1.0, 1.0)},
{'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0.5, 0.75, 1.0), 'B': (0, 0.55, 1.0)}]
Just draw the boxes on a piece of napkin and convince yourself that this
is a good change.
If the ratios are equal, we cut against the first axis in the axisOrder:
behdad:fonttools 0 (master)$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .5,.5 .75,.75
Sorted locations:
[{},
{'A': 1.0},
{'B': 1.0},
{'A': 1.0, 'B': 1.0},
{'A': 0.5, 'B': 0.5},
{'A': 0.75, 'B': 0.75}]
Supports:
[{},
{'A': (0, 1.0, 1.0)},
{'B': (0, 1.0, 1.0)},
{'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0.5, 0.75, 1.0), 'B': (0, 0.75, 1.0)}]
2018-04-27 16:50:32 -07:00
Behdad Esfahbod
1917d6913b
[subset] Remove more nonsensical code
...
Remaining parts of 4e3192163470ca168ff753cb526480e59bc77e1a
2018-04-25 16:09:30 -07:00
Cosimo Lupo
c616e10e45
varLib: add --master-finder option
...
Takes a template containing predefined strings {dirname}, {basename},
{stem}, {ext} and {fullname}, to customize the location of the binary
master TTFs in relation to the designspace source filenames.
2018-04-25 13:19:58 +01:00
Cosimo Lupo
3fe84a65ea
[varLib.mutator] prune fvar nameIDs from instance's name table
...
Fixes https://github.com/fonttools/fonttools/issues/1227
2018-04-18 12:35:54 +01:00
Cosimo Lupo
ffc7dfc23d
[varLib] don't need to read nameTable in _add_stat
...
for now at least...
2018-04-16 12:55:51 +02:00
Cosimo Lupo
08c30e9fde
[varLib] make STAT v1.2, reuse fvar nameIDs
...
Fixes https://github.com/googlei18n/fontmake/issues/417
2018-04-16 12:40:02 +02:00
Behdad Esfahbod
6a88c39834
[varLib.plot] Show master locations
2018-04-14 14:43:42 +02:00
Behdad Esfahbod
113558ac7d
[varLib.plot] Set axis limits to -1,+1
2018-04-13 18:48:34 +02:00
Cosimo Lupo
0055f9414c
models: convert delta array to float if overflows signed short integers
...
We should check other places where such overflows may occur and do the same.
Or do maybe it in GlyphCoordinates class.
2018-04-03 11:40:44 +01:00
Behdad Esfahbod
a523a69716
[varLib.models] Improve model
...
When adding a master and computing its support, when hitting another master,
we don't need to limit our box in every direction; we just need to limit in
one so we don't hit the older master with our support. Implement heuristic
that takes the first axis that minimizes the area loss.
This is not perfect, but a good improvement.
Before:
$ fonttools varLib.models 0,0 0,1 1,0 1,1 .4,0 .6,1 .5,.5 .7,.9Sorted locations:
[{},
{'A': 0.4},
{'A': 1.0},
{'B': 1.0},
{'A': 1.0, 'B': 1.0},
{'A': 0.6, 'B': 1.0},
{'A': 0.5, 'B': 0.5},
{'A': 0.7, 'B': 0.9}]
Supports:
[{},
{'A': (0, 0.4, 1.0)},
{'A': (0.4, 1.0, 1.0)},
{'B': (0, 1.0, 1.0)},
{'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.6, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0.5, 0.7, 1.0), 'B': (0.5, 0.9, 1.0)}]
After:
$ fonttools varLib.models 0,0 0,1 1,0 1,1 .4,0 .6,1 .5,.5 .7,.9
Sorted locations:
[{},
{'A': 0.4},
{'A': 1.0},
{'B': 1.0},
{'A': 1.0, 'B': 1.0},
{'A': 0.6, 'B': 1.0},
{'A': 0.5, 'B': 0.5},
{'A': 0.7, 'B': 0.9}]
Supports:
[{},
{'A': (0, 0.4, 1.0)},
{'A': (0.4, 1.0, 1.0)},
{'B': (0, 1.0, 1.0)},
{'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.6, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0, 0.7, 1.0), 'B': (0.5, 0.9, 1.0)}]
(Note the last line.)
2018-03-28 02:11:49 -07:00
Behdad Esfahbod
28000a4195
[varLib.plot] Display master names
2018-03-28 01:57:59 -07:00
Behdad Esfahbod
34458fe347
[varLib.plot] Label axes
2018-03-28 01:44:27 -07:00
Behdad Esfahbod
0359daad3d
Revert "[varLib.models] Improve modeling"
...
This reverts commit e4d363cc5c14471b02a98657e9bc04b75109c687.
2018-03-28 01:38:10 -07:00
Behdad Esfahbod
7504bde11b
[varLib.plot] Take input like varLib.models does
...
Eg.:
$ fonttools varLib.plot 0,0 0,1 1,0 1,1 .4,0 .6,1 .5,.5 .7,.7 .6,.9 .9,.6
2018-03-28 01:35:18 -07:00
Behdad Esfahbod
049020d52c
[varLib.plot] Draw a subplot for each master
...
Looks much nicer now.
2018-03-28 01:24:52 -07:00
Behdad Esfahbod
e4d363cc5c
[varLib.models] Improve modeling
...
After:
jj
2018-03-28 01:17:54 -07:00
Cosimo Lupo
2ef60fa989
varLib.mutator: add -o option, use argparse
2018-03-27 14:06:37 +01:00
Behdad Esfahbod
1bf955fb08
Err, forgot to link issue to previous commit
...
https://github.com/googlei18n/fontmake/issues/264
2018-03-26 20:46:26 -07:00
Behdad Esfahbod
42bef176a3
[varLib] Tweak support-resolution algorithm
...
Improve varLib model algorithm.
This, basically means any varfont built that had an unusual master
configuration will change when rebuilt.
Here's a good test: a two-axis with 8 masters at unusual locations:
2-----------------5----------3
| |
| 7 |
| |
| 6 |
| |
| |
| |
0-----------4----------------1
Previously, the reach of master 3 (Black Extended) would
have started from A=.4, ie, the A position of master 4.
It now correctly starts from 0. Same thing with masters
after it. Ie, master 5 gets a span on the A axis from
0 to 1, whereas before it was getting from .4 to 1.
Previously, the on-axis masters always cut the space. They
don't anymore. That's more consistent, and fixes the main
issue Erik showed at TYPO Labs 2017. Same issue was also
causing the reach of master 3 to be limited, which I think
is the issue being discussed in the linked issue. Both should
be fixed.
It's hard to describe exactly what happened before / after.
Best to read the actual support values:
Before:
Sorted locations:
$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .4,0 .6,1 .5,.5 .7,.7
[{},
{'A': 0.4},
{'A': 1.0},
{'B': 1.0},
{'A': 1.0, 'B': 1.0},
{'A': 0.6, 'B': 1.0},
{'A': 0.5, 'B': 0.5},
{'A': 0.7, 'B': 0.7}]
Supports:
[{},
{'A': (0.0, 0.4, 1.0)},
{'A': (0.4, 1.0, 1.0)},
{'B': (0.0, 1.0, 1.0)},
{'A': (0.4, 1.0, 1.0), 'B': (0.0, 1.0, 1.0)},
{'A': (0.4, 0.6, 1.0), 'B': (0.0, 1.0, 1.0)},
{'A': (0.4, 0.5, 1.0), 'B': (0.0, 0.5, 1.0)},
{'A': (0.5, 0.7, 1.0), 'B': (0.5, 0.7, 1.0)}]
After:
$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .4,0 .6,1 .5,.5 .7,.7
Sorted locations:
[{},
{'A': 0.4},
{'A': 1.0},
{'B': 1.0},
{'A': 1.0, 'B': 1.0},
{'A': 0.6, 'B': 1.0},
{'A': 0.5, 'B': 0.5},
{'A': 0.7, 'B': 0.7}]
Supports:
[{},
{'A': (0, 0.4, 1.0)},
{'A': (0.4, 1.0, 1.0)},
{'B': (0, 1.0, 1.0)},
{'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.6, 1.0), 'B': (0, 1.0, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0.5, 0.7, 1.0), 'B': (0.5, 0.7, 1.0)}]
TODO: We should add this as a test case.
There's another improvement I want to make, but that's separate.
2018-03-26 20:32:27 -07:00
Behdad Esfahbod
05e2ec4d3a
[varLib.models] Add main()
...
Takes positions and prints model results:
$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .4,0 .6,1 .5,.5
Sorted locations:
[{},
{'A': 0.4},
{'A': 1.0},
{'B': 1.0},
{'A': 1.0, 'B': 1.0},
{'A': 0.6, 'B': 1.0},
{'A': 0.5, 'B': 0.5}]
Supports:
[{},
{'A': (0.0, 0.4, 1.0)},
{'A': (0.4, 1.0, 1.0)},
{'B': (0.0, 1.0, 1.0)},
{'A': (0.4, 1.0, 1.0), 'B': (0.0, 1.0, 1.0)},
{'A': (0.4, 0.6, 1.0), 'B': (0.0, 1.0, 1.0)},
{'A': (0.4, 0.5, 1.0), 'B': (0.0, 0.5, 1.0)}]
2018-03-26 20:10:15 -07:00
Behdad Esfahbod
2349ff37fd
[fontTools.varLib.plot] New module to plot a designspace's VariationModel
...
The visualization is not as useful as I was hoping would be :(.
2018-03-26 18:42:23 -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
Cosimo Lupo
168c7e1cd3
[varLib] rename --disableIUP to --disable-iup
2018-03-06 12:46:27 +01:00
Rob McKaughan
4b44d97920
Add flag to disable IUP optimization
2018-03-05 15:32:17 -08:00
Cosimo Lupo
ad7b97a7b2
[varLib.mutator] clamp width to 0 if left/right phantom points are swapped
...
https://github.com/fonttools/fonttools/pull/1198
2018-02-28 15:13:59 +00: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
Behdad Esfahbod
88343d2367
[varLib.mutator] Fix comment
2018-02-21 14:54:27 -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
398f7169c8
[varLib] Optimize MVAR VarStore
2018-02-21 00:55:39 -08:00
Behdad Esfahbod
7aef5c8072
[varLib] Optimize GDEF VarStore when generating varfonts
...
Sweet...
2018-02-21 00:22:14 -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
d5efd2b7ee
[varLib] When optimizing NumShorts, drop zero columns
...
Related to https://github.com/fonttools/fonttools/issues/1184
2018-02-20 20:51:56 -08:00
Behdad Esfahbod
323783d41c
[varLib] Allow excluding arbitrary tables
2018-02-19 19:16:35 -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
ca7cd85731
[varLib] Add a couple of commandline options
2018-02-19 17:18:27 -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
48125e9812
[varLib] Fix HVAR generation
...
We cannot tail-optimize there.
2018-02-18 22:58:47 -08:00
Behdad Esfahbod
f3def2ea5a
[subset] Fix pruning of GDEF VarStore
2018-02-18 22:37:44 -08:00
Behdad Esfahbod
21cbab8ce9
Fix read/write of VarIdxMap to use glyph names
...
Was relying on glyph IDs. Ouch.
2018-02-18 22:33:32 -08:00
Behdad Esfahbod
eb6af2da72
[varLib] Fix pruning of HVAR
2018-02-18 21:49:39 -08:00
Behdad Esfahbod
23d373caac
[varLib] Comment
2018-02-18 21:45:27 -08:00