Referencing glyph metrics in feature code using tokens

Is there a way to reference glyph metrics in feature code? Say, I want to shift something by the width of the space glyph, something like pos A ${glyph("space").layer0.width};.

Yes, ${space:width} should do it. Have a look at the Glyph Property Tokens section the the Handbook for a list of all supported properties.

1 Like

Excellent, thanks.

I only checked the tutorial page, but I guess I should consult the handbook more.

With the release of 3.2, there will also be a web version of the Handbook. I find that easier to quickly consult.


OK, this seems to work but how I make the value negative? I tried -${space:width} but it gives a syntax error, and I tried ${space:width*-1} and it works except for glyphs with a hyphen in their name e.g. ${endofayah-ar:width*-1} gives a syntax error. Actually no arithmetic works for glyphs with hyphen in the name.

Regarding -${space:width}: I think this should work, but it might be complicated by how the feature code is compiled.

Regarding ${endofayah-ar:width*-1}: This is a general issues with arithmetic expressions and hyphens in glyph names. We are working on a better parser that can handle cases like this that are currently ambiguous, but I’m not sure when that will be ready to launch.

OK, I’ll go with this and hope it gets fixed soon. With this PR glyphsLib support glyph property tokens and either way of negation works.