I’m constructing GSFontInfoValue in Glyphs 3, and add it to the font. But the script doesn’t run anymore in Glyphs 4:
ImportError: cannot import name 'GSFontInfoValue' from 'GlyphsApp'
(/Applications/Glyphs 4.app/Contents/Scripts/GlyphsApp/__init__.py).
Did you mean: 'GSInfoValue'?
I don’t think GSInfoValue is the correct replacement, or is it?
Yes. There were many classes with “GSFontInfo…” and that got in the way when code completion would suggest them when I need GSFont. And some of them live in masters or instances. So I removed the “Font”.
Glyphs 3 still uses the “GSFontInfoValue”. There is a “GSInfoValue” in Glyph 3, but that is something else. Can you show what you are trying to do? I don’t think you need to deal with those objects directly. You should be able to use
I fixed the master.metrics.items(). This is how it works internally:
def items(self) -> Iterator[Tuple[str, GSMetricStore]]:
if self._owner.font is None:
return
for metric in self._owner.font.metrics:
yield (metric.id, self._owner.valueForMetric_(metric))
actually iterating the metrics on the font and then get each value from the master (it is stored as a dict internally).
Actually I’m trying to import AFDKO feature code into a Glyphs font. During that, I interpret the first comment line in a ssXX feature as the friendly feature name, and want to add it to the feature.
if "#" in line:
_, comment = line.split("#", 1)
label = GSFontInfoValue()
label.languageTag = "dflt"
label.value = comment.strip()
feature_code.append(line)
# ...
gsfea = GSFeature(tag, "\n".join(feature_code))
if label is not None:
gsfea.labels.append(label)
(This is in a file format plugin, so importing the feature code via File – Import – Features… is not feasible.)
I found that to be unreliable, that’s why I wrote my own logic. And I would need to process the feature file anyway, to extract the comment line in Stylistic Set features to the friendly feature name.