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
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