3301: Can't set hint.stem with negative value programatically

for glyph in Glyphs.font.glyphs:
	for layer in glyph.layers:
		if layer.hints:
			for hint in layer.hints:
				if hint.isTrueType and hint.horizontal and hint.type == TTSTEM:
						hint.options = TTDONTROUND
						hint.stem = -1

gives me an error of:

Traceback (most recent call last):
  File "<macro panel>", line 409
  File "GlyphsApp/GlyphsApp/__init__.py", line 11956, in <lambda>
  File "GlyphsApp/GlyphsApp/__init__.py", line 11949, in GSHint__setStem__
ValueError: Wrong value. Stem values can be indices of TT stems ("TTFStems" master custom parameter) or -1 for no stem or -2 for automatic.

I believe this used to workā€¦ how long ago I donā€™t remember :sweat_smile:

in case anyone else runs into this, a workaround is hint.setStem_(-1) though it isnā€™t documented

The setter expects that you have added a ā€œTTFStemsā€ custom parameter in the master settings. But there was also an error in the setter code. That I finally fixed. So thanks for the reminder.

1 Like

aha, thank you. just to clarify - the TTFStems parameter is unnecessary if all the hints are set to ā€œno stemā€ and/or if your PS/TT hints arenā€™t different? I assume the master-level stems get used by default and the TTFStems parameter is only used if defined?

Side question: why do you like to change the stem in the first place? In almost all cases, you just leave it on ā€˜autoā€™.

I have been testing different strategies for variable fonts, no stem seems to work better in some apps. but I am starting to lean toward no hinting at all in variable fonts. outside VF, ā€œno stemā€ also seems to work better in some glyphs in terms of how it distorts the red-colored preview outline, but I donā€™t know that it affects the actual rendering much if at all

If you do not use stems, you can use align instructions, instead of stem instructions. Those are basically stems without stem == -1.