-
Notifications
You must be signed in to change notification settings - Fork 476
varLib. Use designspace <axes> element to define the axisMap and order. #857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…he axis map, and preserve the axis order.
Lib/fontTools/varLib/__init__.py
Outdated
@@ -59,7 +60,9 @@ def _add_fvar(font, axes, instances, axis_map): | |||
font['fvar'] = fvar = newTable('fvar') | |||
nameTable = font['name'] | |||
|
|||
for iden in sorted(axes.keys(), key=lambda k: axis_map[k][0]): | |||
for iden in axis_map.keys(): | |||
if not axes.has_key(iden): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to use in
instead of has_key
, as that no longer exists in py3
@@ -29,6 +29,7 @@ | |||
from fontTools.ttLib.tables import otTables as ot | |||
from fontTools.varLib import builder, designspace, models | |||
from fontTools.varLib.merger import VariationMerger | |||
import collections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used downstream
@@ -1,5 +1,6 @@ | |||
"""Rudimentary support for loading MutatorMath .designspace files.""" | |||
from __future__ import print_function, division, absolute_import | |||
import collections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to do from collections import OrderedDict
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it would make any difference.
The designspace_test.py also needs to be modified (that's why CI are failing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess if you use OrderedDict
more than once, you can spare an extra attribute lookup if you import from
, as Miguel suggested.
@behdad ok then you can merge it. The CI will still fail as the tests needs to be adjusted. |
@anthrotype I can take care of the fixes |
Thanks Read and Miguel. |
Here is a method to use the designspace element to define the axis map, and preserve the axis order. If the element does not exist, still uses the standard_map, but with the order preserved.