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
[designspaceLib] splitVariableFonts
loses filename
attribute in <variable-fonts>
#3308
Comments
Can you provide an example that does not use ufoProcessor? |
Oops yes. Looks like it has something to do with how I used the from fontTools.designspaceLib import DesignSpaceDocument
from ufoProcessor.ufoOperator import UFOOperator
# Straight from fontTools
doc = DesignSpaceDocument()
doc.read('/Users/Ryan/Desktop/test.designspace')
vf = doc.getVariableFonts()
print(vf[0].filename)
# UFOOperator, useVariableFonts=True
operator = UFOOperator('/Users/Ryan/Desktop/test.designspace')
for name, interpolableOperator in operator.getInterpolableUFOOperators(useVariableFonts=True):
vf = interpolableOperator.getVariableFonts()
print(vf[0].filename)
# UFOOperator, useVariableFonts=False
for name, interpolableOperator in operator.getInterpolableUFOOperators(useVariableFonts=False):
vf = interpolableOperator.getVariableFonts()
print(vf[0].filename) Output:
|
@justvanrossum from fontTools.designspaceLib import DesignSpaceDocument
from fontTools.designspaceLib.split import splitInterpolable, splitVariableFonts
# Getting the <variable-fonts> filename from the flat document works.
doc = DesignSpaceDocument()
doc.read('/Users/Ryan/Desktop/test.designspace')
vf = doc.getVariableFonts()
print(vf[0].filename)
# Still works with splitInterpolable
split_interp = splitInterpolable(doc)
for name, interp in split_interp:
vf = interp.getVariableFonts()
print(vf[0].filename)
# Loses filename with splitVariableFonts
split_var = splitVariableFonts(doc)
for name, var in split_var:
vf = var.getVariableFonts()
print(vf[0].filename) Output:
I think it's happening around here:
|
getVariableFonts
is not getting the right filename
splitVariableFonts
loses filename
attribute in <variable-fonts>
I'm not sure what's going on here, and I hope @belluzj can shed some light on this. |
Hello, here is an explanation of what is going on, although it's not an excuse and the code could be be improved:
Possible workaround for now: zip your split_var = splitVariableFonts(doc)
for vf, (name, varDoc) in zip(doc.getVariableFonts(), split_var):
print(vf[0].filename) Possible improvement: make Does that help? |
Hi @belluzj, thanks for looking into this. I understand the initial thinking, and the improvement proposal makes sense to me! Thanks for the workaround as well. |
I may be doing something wrong here. But I can't seem to get the
filename
attribute from a<variable-fonts>
tag in a designspace file.fonttools/Lib/fontTools/designspaceLib/__init__.py
Line 3210 in 6e1f55b
Here's a test ds file I'm using:
The code I'm using to try and get the filename:
This is the output:
It's able to get the correct axis subset name, but not the filename.
TIA!
The text was updated successfully, but these errors were encountered: