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

VF settings fixup for #812/#813 #815

Merged
merged 6 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions Lib/glyphsLib/builder/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from fontTools.varLib.models import piecewiseLinearMap

from glyphsLib import classes
from glyphsLib.classes import WEIGHT_CODES, WIDTH_CODES
from glyphsLib.classes import INSTANCETYPEVARIABLE, WEIGHT_CODES, WIDTH_CODES
from glyphsLib.builder.constants import WIDTH_CLASS_TO_VALUE

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -186,7 +186,7 @@ def to_designspace_axes(self):
for instance in self.font.instances:
if (
is_instance_active(instance) or self.minimize_glyphs_diffs
) and instance.type != "variable":
) and instance.type != INSTANCETYPEVARIABLE:
designLoc = axis_def.get_design_loc(instance)
userLoc = axis_def.get_user_loc(instance)
if (
Expand Down
11 changes: 8 additions & 3 deletions Lib/glyphsLib/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
OFFCURVE = "offcurve"
QCURVE = "qcurve"

INSTANCETYPESINGLE = 0
INSTANCETYPEVARIABLE = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be defined in https://github.com/googlefonts/glyphsLib/blob/main/Lib/glyphsLib/builder/constants.py maybe? The same probably applies for the other constants defined in here, at least those that are imported by other modules and not private to the current one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving it there leads to circular imports. It's not immediately obvious to me how to avoid that ...


TAG = -2
TOPGHOST = -1
STEM = 0
Expand Down Expand Up @@ -3061,13 +3064,13 @@ def _serialize_to_plist(self, writer):
self, "widthValue", keyName="interpolationWidth", default=100
)
writer.writeObjectKeyValue(self, "instanceInterpolations", "if_true")
if writer.format_version > 2 and self.type == INSTANCETYPEVARIABLE:
writer.writeValue("variable", "type")
writer.writeObjectKeyValue(self, "isBold", "if_true")
writer.writeObjectKeyValue(self, "isItalic", "if_true")
writer.writeObjectKeyValue(self, "linkStyle", "if_true")
writer.writeObjectKeyValue(self, "manualInterpolation", "if_true")
writer.writeObjectKeyValue(self, "name")
if writer.format_version > 2:
writer.writeObjectKeyValue(self, "type", "if_true")
writer.writeObjectKeyValue(
self, "weight", default="Regular", keyName="weightClass"
)
Expand All @@ -3083,6 +3086,7 @@ def _serialize_to_plist(self, writer):
"weightClass": "Regular",
"widthClass": "Medium (normal)",
"instanceInterpolations": {},
"type": INSTANCETYPESINGLE,
}

def __init__(self):
Expand All @@ -3102,7 +3106,7 @@ def __init__(self):
self.visible = True
self.weight = self._defaultsForName["weightClass"]
self.width = self._defaultsForName["widthClass"]
self.type = ""
self.type = self._defaultsForName["type"]

customParameters = property(
lambda self: CustomParametersProxy(self),
Expand Down Expand Up @@ -3296,6 +3300,7 @@ def customValue3(self, value):
{"plist_name": "axesValues", "object_name": "axes"},
{"plist_name": "manualInterpolation", "converter": bool},
{"plist_name": "properties", "type": GSFontInfoValue},
{"plist_name": "type", "converter": bool},
jenskutilek marked this conversation as resolved.
Show resolved Hide resolved
]
)

Expand Down