What happened to GSFontInfoValue in G4?

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?

When I try to use GSInfoValue, the script doesn’t run in Glyphs 3 anymore:

AttributeError: 'GSInfoValue' object has no attribute 'languageTag'

Also, this doesn’t work anymore in Glyphs 4:

from GlyphsApp import Glyphs
for key, metric in Glyphs.font.masters[0].metrics.items():
	print(key, metric)

Result:

Traceback (most recent call last):
  File "Macro 2.py", line 2
  File "__init__.py", line 618, in items
    yield (self.getKeyOf(v), v)
           ~~~~~~~~~~~~~^^^
  File "__init__.py", line 3121, in getKeyOf
    raise NotImplementedError()
NotImplementedError

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

- (void)setProperty:(GSPropertyName)name value:(id)value languageTag:(nullable NSString *)languageTag;

and related method of the font or instance. GSFont setProperty:value:languageTag: — Glyphs API Documentation

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.)

Just to be sure. Did you try:

GSFont
 - (BOOL)importFeatures:(NSString *)feaString error:(out NSError **)error;

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.

I see. I’ll have a look at the feature name import. Should be done in Glyphs, too. Any other suggestions?

The labels are “GSInfoValueLocalized”.