Cosimo Lupo
2dedea5f8f
models: remove unused axisOrder argument from _computeMasterSupports private method
...
it's no longer used in the body of the method. If needed, it's accessible from self.axisOrder
2019-03-04 16:58:15 -08:00
Cosimo Lupo
f8c7950e48
models: minor: explicitly test for axisOrder is None
...
389cf7c56a (r32585140)
2019-03-04 16:51:53 -08:00
Cosimo Lupo
05824b8616
VariationModel: assert that locations are unique
2019-03-04 11:42:54 -08:00
Cosimo Lupo
d8152feb21
VariationModels: remove unused lowerBound/upperBound static methods
2019-03-04 11:15:06 -08:00
Cosimo Lupo
389cf7c56a
VariationModel: don't use mutable list default value for 'axisOrder' parameter
2019-03-04 10:58:47 -08:00
Cosimo Lupo
148b421705
models.main: actually pass normalized master locations to VariationModel
2019-03-01 13:04:52 -08:00
Behdad Esfahbod
31019eac8e
[CFF] Whitespace
2018-11-30 21:46:16 -05:00
ReadRoberts
331a55588b
[varlib] update model.reorderMasters() to support arbitrary mapping.
2018-11-30 10:37:34 -08:00
ReadRoberts
29b1246515
[varlib] Move master list reordering into models.py
...
It is useful to re-order the CFF2 master font list to match the sorted location order, but doing so means touching internal fields of the model, so we'll move this into the VariationModel class.
2018-11-30 09:12:27 -08:00
Behdad Esfahbod
5c1ca73123
[varLib] Rename allSame() to allEqual()
...
Being same ("is") is not the same as being equal ("=="), even though
the two are equal most of the time.
2018-11-10 15:06:07 -05:00
Behdad Esfahbod
7711755b2c
[varLib] Add mapper to allSameAs() and use it
2018-11-09 09:51:53 -05:00
Behdad Esfahbod
bff73edcfd
[varLib] Add models.allNone
2018-11-09 09:48:02 -05:00
Behdad Esfahbod
7cda1c1a97
[varLib] Add models.allSameAs()
2018-11-08 23:41:09 -05:00
Behdad Esfahbod
14e8c06565
[varLib] Fixups
...
Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 12:29:07 -05:00
Behdad Esfahbod
b95967dd07
[varLib] Add models.allSame() and use it
...
Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 11:36:58 -05:00
Behdad Esfahbod
fba530a548
[varLib] Add VariationModel.getDeltasAndSupports()
...
which automatically fetches submodel. Needs docstrings...
Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 11:31:44 -05:00
Behdad Esfahbod
6886075a23
[varLib] rename .modelFor() to .getSubModel()
...
Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 11:31:42 -05:00
Behdad Esfahbod
23c58e91d0
[varLib] Allow sparse masters for CVT tables
...
Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 11:31:41 -05:00
Behdad Esfahbod
65bcbf8ac2
[varLib] Implement getting subModels
...
To be used for sparse masters.
Part of https://github.com/googlei18n/fontmake/issues/88
Part of https://github.com/fonttools/fonttools/issues/1355
2018-11-08 11:31:25 -05:00
Behdad Esfahbod
62003f492f
[varLib] If multiple axes have the same range ratio, cut across both
...
The symmetry is desired.
Before:
$ ./fonttools varLib.models 0,0 .5,0 0,.5 .5,.5 1,1
Sorted locations:
[{}, {'A': 0.5}, {'B': 0.5}, {'A': 0.5, 'B': 0.5}, {'A': 1.0, 'B': 1.0}]
Supports:
[{},
{'A': (0, 0.5, 1.0)},
{'B': (0, 0.5, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0.5, 1.0, 1.0), 'B': (0, 1.0, 1.0)}]
Note the last line assymetry.
After:
$ ./fonttools varLib.models 0,0 .5,0 0,.5 .5,.5 1,1
Sorted locations:
[{}, {'A': 0.5}, {'B': 0.5}, {'A': 0.5, 'B': 0.5}, {'A': 1.0, 'B': 1.0}]
Supports:
[{},
{'A': (0, 0.5, 1.0)},
{'B': (0, 0.5, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0.5, 1.0, 1.0), 'B': (0.5, 1.0, 1.0)}]
7ee81c8821 (commitcomment-31054804)
2018-10-28 09:30:09 -07:00
Cosimo Lupo
6a5a4c7422
varLib.models: fix TypeError comparing float with None
2018-10-26 11:07:12 +01:00
Behdad Esfahbod
7ee81c8821
[varLib] Take total bounding box into account when resolving model
...
Umm. Not sure how useful this is, but helps with cases where there
were not masters on extremes and people expected this to work.
Happens in Higher-Order Interpolation since the axis extremes
are not interesting.
Fixes https://github.com/googlei18n/fontmake/issues/473
Test case (in case someone wants to add it to test suite!):
Before:
$ ./fonttools varLib.models 0,0 .5,0 0,.5 .5,.5 1,1
Sorted locations:
[{}, {'A': 0.5}, {'B': 0.5}, {'A': 0.5, 'B': 0.5}, {'A': 1.0, 'B': 1.0}]
Supports:
[{},
{'A': (0, 0.5, 0.5)},
{'B': (0, 0.5, 0.5)},
{'A': (0, 0.5, 0.5), 'B': (0, 0.5, 0.5)},
{'A': (0.5, 1.0, 1.0), 'B': (0, 1.0, 1.0)}]
After:
$ ./fonttools varLib.models 0,0 .5,0 0,.5 .5,.5 1,1
Sorted locations:
[{}, {'A': 0.5}, {'B': 0.5}, {'A': 0.5, 'B': 0.5}, {'A': 1.0, 'B': 1.0}]
Supports:
[{},
{'A': (0, 0.5, 1.0)},
{'B': (0, 0.5, 1.0)},
{'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
{'A': (0.5, 1.0, 1.0), 'B': (0, 1.0, 1.0)}]
2018-10-25 19:46:44 -07: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
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
e75d6a8ca1
[varLib.models] add assertion debug message
...
Fixes #1268
2018-06-14 15:34:27 +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
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
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
0359daad3d
Revert "[varLib.models] Improve modeling"
...
This reverts commit e4d363cc5c14471b02a98657e9bc04b75109c687.
2018-03-28 01:38:10 -07:00
Behdad Esfahbod
e4d363cc5c
[varLib.models] Improve modeling
...
After:
jj
2018-03-28 01:17:54 -07: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
cca7a79018
[varLib] Adjust for supportScalar() default ot=True change
...
Fixup for 028ed0125244531215d4d774474d929acda14d49
2017-10-19 10:07:08 -07:00
justvanrossum
2f6ec32ff0
oops, forgot to adapt doctests; thanks @anthrotype\!
2017-10-18 10:29:19 +02:00
justvanrossum
028ed01252
set default value of the ot argument to True, as discussed in a1629fa52b
2017-10-18 10:04:42 +02:00
Cosimo Lupo
dfeacfba36
[varLib.models] minor
...
We need to use float (0.) rather than int (0) for the normalized axis
origin, otherwise some varLib roundtrip tests may fail.
E.g.
```diff
<tuple>
- <coord axis="wght" max="1.0" min="0.0" value="0.61"/>
+ <coord axis="wght" max="1.0" min="0" value="0.61"/>
```
2017-08-16 16:35:57 +01:00
Behdad Esfahbod
a1629fa52b
[varLib] Update supportScalar() to allow for OpenType-specific contraints
...
Part of https://github.com/fonttools/fonttools/issues/1020
2017-08-07 17:05:29 -07:00
justvanrossum
18fa7ccec0
supportScalar(): ignore an axis when its peak value is 0; fixes #1020
2017-08-07 13:16:24 +02:00
Erik van Blokland
4762865cac
Makes it a bit easier to find out what is wrong with the values.
2017-08-05 20:37:37 +02:00
Behdad Esfahbod
dbc54a2429
[varLib.models] Mark VariationModel.interpolateFromDeltasAndScalars static
...
This correctly reflects that all we need to interpolate is deltas and
scalars.
2017-05-23 01:01:07 -07:00
Behdad Esfahbod
39d059ef08
Revert "[varLib.models] Minor"
...
This reverts commit 49df768cd3d1dd2c39933e3c07d214013d50ef60.
That was accidentally pushed!
2017-05-23 00:54:23 -07:00
Behdad Esfahbod
bc546dec10
[varLib.models] Add VariationModel.interpolateFromMastersAndScalars()
2017-05-23 00:54:11 -07:00
Behdad Esfahbod
53b7ea4612
[varLib.models] Add VariationModel.interpolateFromDeltasAndScalars()
2017-05-23 00:54:11 -07:00
Behdad Esfahbod
489c80c83b
[varLib.models] Add VariationModel.getScalars()
...
To factor out scalar computation out of each interpolation.
2017-05-23 00:54:11 -07:00
Behdad Esfahbod
adc4fe960e
[varLib.models] Remove unused line
2017-05-23 00:54:11 -07:00