Mapping a glyph name to small caps

Is there some function to get a matching small cap name for a given glyph name? Something like this:

>> getSmallCapName("AEacute")
aeacute.sc

To answer my own question:

g = GSGlyphsInfo.alloc().init()
print(f"{g.lowerCaseName_('AEacute')}.sc")
1 Like

I don’t understand how that’s different from

print("%s.sc" % "AEacute".lower())

Ah, maybe I was thinking that I would need the reverse operation eventually: aeacute.sc → AEacute. But the GSGlyphsInfo method doesn’t solve that either :-/

The official way is to use the Unicode (or better info.unicharString() and do a lower()/upper() on it.

Have a look at the headers of GSGlyphsInfo and GSGlyphInfo in the GlyphsCore framework. There are some useful methods for stuff like this.

Thank you!

You may be lucky with .lower() in most cases but it will fail on glyph names such as yuReversed-cy or Adieresis.loclDEU etc. The uppercase/lowercase relationship is a bit more delicate than simply casefolding everything.