488 Commits

Author SHA1 Message Date
Behdad Esfahbod
d258333007 [iup] Fix comment 2018-09-27 17:41:09 -04:00
Cosimo Lupo
9f18570aac
implement building GSUB FeatureVariations from DS rules
Fixes https://github.com/fonttools/fonttools/issues/1176
2018-09-14 16:16:33 +02:00
Cosimo Lupo
26ddbcfe46
varLib: return a namedtuple from load_designspace
so we can also return the list of parsed rule elements
2018-09-12 19:16:13 +02:00
Cosimo Lupo
8080690c74
interpolate_layout: use DesignSpaceDocument instead of varLib.designspace 2018-09-11 18:33:07 +02:00
Cosimo Lupo
5457270775
designspaceLib: 'axes' element is required by DesignSpaceDocument, remove fallback code 2018-09-11 18:25:43 +02:00
Cosimo Lupo
0f4bdf65e6
varLib: use designspaceLib instead of varLib.designspace
and replace _DesignspaceAxis with AxisDescriptor
2018-09-11 18:16:52 +02:00
Cosimo Lupo
c960a361a8
mutator: use piecewiseLinearMap instead of _DesignspaceAxis._map 2018-09-11 18:07:15 +02:00
Cosimo Lupo
8900505200
models: add piecewiseLinearMap function
copied from fontTools.varLib._DesignspaceAxis._map static method.
I place it here since it is also used by varLib.mutator, so makes sense
to have a public function
2018-09-11 18:06:06 +02:00
Cosimo Lupo
5f1844165e
varLib.designspace: add a deprecation warning 2018-09-11 18:02:49 +02:00
Cosimo Lupo
8c597b5375
mutator: round to closest width class
this is the mapping between the half of each percentage intervals and
the associated usWidthClass:

{56.25: 1,
 68.75: 2,
 81.25: 3,
 93.75: 4,
 106.25: 5,
 118.75: 6,
 137.5: 7,
 175.0: 8}

Notice how wdth=80 (in the adjusted test case) will fall in width class
3, instead of 4, because it is < 81.25, thus closer to the nominal 75
than to 87.5.
2018-06-19 14:16:17 +01:00
Cosimo Lupo
0234b9dbd5
mutator: also clamp usWeightClass between valid 1...1000 2018-06-18 19:45:20 +01:00
Cosimo Lupo
dbe08a62ad
mutator: set usWeightClass, usWidthClass and italicAngle
https://github.com/fonttools/fonttools/issues/1264
2018-06-18 19:40:30 +01:00
Behdad Esfahbod
a3a25e09b2 [varLib.models] Rename variables for clarity 2018-06-17 18:47:53 -04:00
Behdad Esfahbod
09ae567070 [varLibs.models] Another fix
Though, the previous work was also working; the bug couldn't be hit.
2018-06-16 14:17:44 -04:00
Behdad Esfahbod
1801248938 [varLib.models] Fix model resolution
Oops.  Was introduced when I last changed modeling.

The problem was, for checking that a previous master m is outside the current
influence box of the current master, I was doing "not (lower < m[loc] < upper)".
This is wrong, where lower,peak,upper is the support of previous master.
This fails if lower == peak == m[loc], or m[loc] == peak == upper.

Fixes https://github.com/fonttools/fonttools/issues/1269#issuecomment-397655016
2018-06-16 14:07:18 -04:00
Behdad Esfahbod
be9a304dc4 [varLib.models] Allow solving for a .designspace doc from cmdline
Like varLib.plot does.
2018-06-16 13:53:56 -04: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
Cosimo Lupo
e75d6a8ca1
[varLib.models] add assertion debug message
Fixes #1268
2018-06-14 15:34:27 +01:00
Cosimo Lupo
6e9a24b45b
featureVars: mark module as experimental/subject-to-change 2018-06-14 15:25:09 +01:00
Cosimo Lupo
e35151a051
Merge remote-tracking branch 'origin/master' into add-feature-variations 2018-06-11 12:49:31 +01:00
Cosimo Lupo
e48e8ea7c9
Revert "models: convert delta array to float if overflows signed short integers"
This reverts commit 0055f9414ca5094b0c9beb0176ac4998cdbbba70.
2018-06-07 12:53:42 +01:00
Cosimo Lupo
b38e2bd8ac
varLib.plot: use plot, not plot_wireframe, as we are using 1D lists
plot_wireframe requires 2D arrays.

In recent versions of matplotlib passing a 1D array fails with an error:

https://stackoverflow.com/questions/47225830/axes3d-plot-wireframex-y-z-error

https://github.com/matplotlib/matplotlib/pull/5166
https://github.com/matplotlib/matplotlib/issues/3116
2018-06-06 12:43:05 +01:00
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
04dc7339fd
[featureVars] remove unused fvar code; normalized default space is always (-1.0, 1.0) 2018-04-18 12:07:06 +01:00
justvanrossum
978967983c removing normalization step: min/max values are now expected to be given in normalized coordinates 2018-04-18 08:51:45 +02:00
Cosimo Lupo
0f1c6b3cf4
[featureVars] add doctests for non intersecting spaces or regions 2018-04-17 16:53:33 +02:00
Cosimo Lupo
9a04811ec2
[featureVars] use itertools to get combinations of indices
and rename getPermutations to iterAllCombinations.

It's not really permutations we are after here, but more combinations
of indexes sorted by decreasing length, from more specific to less
2018-04-17 15:58:48 +02:00
Cosimo Lupo
d7b4d06882
[varLib] minor: rename variables for clarity; fix mixed tab-space indent
confuses my vim
2018-04-17 14:22:52 +02:00
Cosimo Lupo
0c20948341
clarify coordinates are expressed in 'raw design' values, not 'user'
this is what tripped the whole misunderstanding
2018-04-17 12:31:14 +02:00
Cosimo Lupo
2002a6c92c
Revert "featureVars: modify normalization using avar maps"
This reverts commit 081ca1327c69ad74839b95d3c5096868a5f25532.

https://github.com/fonttools/fonttools/pull/1240#issuecomment-381923485
2018-04-17 12:23:38 +02:00
Cosimo Lupo
081ca1327c
featureVars: modify normalization using avar maps 2018-04-16 18:38:58 +02: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
justvanrossum
4256e6c6bf make doctests independent of dict order repr 2018-04-16 10:33:30 +02:00
justvanrossum
16b7d424dd Module containing a function to add conditional substitutions to a variable font 2018-04-16 10:21:19 +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