Glyphs.registerDefault() always registers "GlyphsToolHand" as value

There is a bug in the Glyphs.registerDefault() method. It always registers the string GlyphsToolHand, no matter what you specify. Paste and run this in the Macro Window:

print Glyphs.defaults["com.mekkablue.testCase"]

Result: GlyphsToolHand :-/

not for me. And registering only sets a default value if nothing was actually set. What happens if you do

print Glyphs.defaults["com.mekkablue.testCase"]

do you have an old in your script folder? Can you rename Script and Plugins folder and restart Glyphs?

Ohhh, I think I saw something like that recently when we struggled to get the Distance and Angle plugin working on @Frode_Helland’s machine. I don’t know exactly what happened, but I remember some wrong default entry happening. I’ll check later …

When I run @mekkablue’s lines from above, the same happens. It prints GlyphsToolHand in build 1122

There has to be something that causes this. Can you try to start without plugins (hold opt+shift when starting the app)?

Same thing I am afraid. Also seen it on other people’s installations. Something wrong in the wrapper maybe?

What happens with

print NSUserDefaults.standardUserDefaults().objectForKey_("com.mekkablue.testCase")

You don’t need to register the defaults every time.

And if you do:

NSUserDefaults.standardUserDefaults().setObject_forKey_(1, "com.mekkablue.testCase")
print NSUserDefaults.standardUserDefaults().objectForKey_("com.mekkablue.testCase")

one more test:

NSUserDefaults.standardUserDefaults().setObject_forKey_(1, NSString.stringWithString_(u"com.mekkablue.testCase"))
print NSUserDefaults.standardUserDefaults().objectForKey_(NSString.stringWithString_(u"com.mekkablue.testCase"))

If that is giving you strange results, then there is something wrong with your system.

This works as expected. Just when I Glyphs.registerDefault() first, it will prepopulate the key’s value with GlyphsToolHand.

It does not matter how I print the value, be it via NSUserDefaults.standardUserDefaults().objectForKey_() or Glyphs.defaults[].

Also, I see this in

def __registerDefaults__(self, defaults):
	if defaults != None:
		raise ValueError
GSApplication.registerDefaults = __registerDefaults__

But Glyphs.registerDefaults({"com.mekkablue.test":1}) yields an AttributeError: ‘GSApplication’ object has no attribute ‘registerDefaults’.

I added that for 1124.

1 Like

@GeorgSeifert: Check the implementation of __registerDefaults__(). I think there might be a typo referencing value versus values at different spots in the method. That might be the cause of this GlyphsHandTool default issue.


You are right. Thanks for finding this.