Skip to content
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

compose DSv5 variable-font filename like Glyphs.app would name exported VFs #982

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Lib/glyphsLib/builder/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,22 @@ def _to_designspace_varfont(self, instance):
from fontTools.ufoLib import fontInfoAttributesVersion3

ds = self.designspace

# unless the `fileName` custom parameter was explicitly set, do like Glyphs.app
# and concatenate the family, instance (style) names and "VF" to form a filename;
# the default 'Regular' is omitted by Glyphs.app.
# https://github.com/googlefonts/glyphsLib/issues/981
filename = instance.customParameters["fileName"]
if not filename:
filename = self.font.familyName
if instance.name != "Regular":
filename += "-" + instance.name
khaledhosny marked this conversation as resolved.
Show resolved Hide resolved
filename += "VF"
filename = filename.replace(" ", "")

ufo_varfont = self.designspace.addVariableFontDescriptor(
name=instance.name,
filename=instance.customParameters["fileName"],
filename=filename,
axisSubsets=[RangeAxisSubsetDescriptor(name=axis.name) for axis in ds.axes],
)

Expand Down
2 changes: 2 additions & 0 deletions tests/builder/axes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@ def test_variable_instance(ufo_module):
assert len(doc.variableFonts) == 1

varfont = doc.variableFonts[0]
assert varfont.name == "Variable Foo Bar"
assert varfont.filename == "Cairo-VariableFooBarVF"
assert len(varfont.axisSubsets) == len(doc.axes)
assert "public.fontInfo" in varfont.lib

Expand Down
2 changes: 1 addition & 1 deletion tests/data/VariableInstance.glyphs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ name = "Name Table Entry";
value = "1 1 0 0; Variable";
}
);
name = Variable;
name = "Variable Foo Bar";
properties = (
{
key = preferredFamilyNames;
Expand Down
Loading