GSFont.newTab(layers) doesn't accept [GSControlLayer(10)]

According to the docs, GSControlLayer(10) is the recommended way of adding line breaks to the list of layers that forms the text in an Edit View tab. However this only seems to work on existing tabs, not on new tabs.

Test script:

text = [
	Font.glyphs['A'].layers[0],
	GSControlLayer(10),
	Font.glyphs['B'].layers[0],
	]
Font.newTab(text)

Error:

Traceback (most recent call last):
  File "<macro panel>", line 6
  File "GlyphsApp/GlyphsApp/__init__.py", line 4369, in __GSFont__addTab__
ValueError: NSInvalidArgumentException - *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]

Have you tried the “string” property. That might be easier.

What Glyphs version is that?

The GSGlyph.string property only works for encoded glyphs.

I was able to work around the issue by creating an empty tab and then assigning the layers to it. I just wanted to report the bug because it’s tripped me up a few times before. I’m running the latest Glyphs 3.1.2 (3151).

its not.

character = font.characterForGlyph_(glyph)

It uses high plane PUA codes for unencoded glyphs. The string property is what Glyphs uses internally.

This is fixed in the latest cutting edge version.

Right, I think I understand how you’re using PUA codes behind the scenes. But are you suggesting that the value of GSGlyph.string is supposed to be a PUA character if the glyph is unencoded? It is always an empty string '' for unencoded glyphs.

For example,

print(f"'{Font.glyphs['a.italic'].string}'")
print(len(Font.glyphs['a.italic'].string))
''
0

You get the code from the method I mentioned above. glyph.string is something else.

@GeorgSeifert I noticed this is still broken in cutting edge 3251. Font.newTab([Layer,GSControlLayer(10),Layer]) no longer throws an error, but it doesn’t put any line breaks in the new tab either. It just ignores them.

I just fixed that this afternoon.

2 Likes

Cheers! I don’t know how you get so much done every day in between dealing with so many support requests. It’s impressive (and much appreciated).

Still broken in 3.3 (3302) :confused:

Fixed it. Thanks for the reminder.

1 Like