Need some guidance on how to write a script for generating .sups and .subs glyphs using components

What I need is a way to be able to generate .sups and .subs glyphs using a script that works similarly to what I have written below. If a script already exists that does something similar ten that should work fine, if not then I would like to some guidance on where to read up on creating such a script. Creating these glyphs manually is starting to consume too much of my time so a solution that utilised a script would be preferred.

If a-cy was selected then a duplicated a-cy.sups glyph should be created using a-cy as a component. This component should have its height and width reduced to a certain specified percentage, in my case 60%, and have its vertical alignment adjusted, in my case 567. .subs glyphs would instead be generated with -440 for its vertical alignment.

An additional difference would be that selected glyphs that end in .pc should be duplicated under .sups.pc instead of .pc.sups, the same should also be true for .sc.

A matching script for generating .subs glyphs is something I would also like to see made.

If using components like you explain, it would produce just smaller versions of the base glyph. You need slightly thicker versions, otherwise it would look bad.

A much better solution is the very useful Remix tools: Font Remix Tools for Glyphs - tutorials It will pay for itself very quickly.

1 Like

Scaled down variants seems to work fine for now. I can’t really see any major issues with their current shapes.

img1

I would prefer to continue to use scaled down shapes until it is deemed necessary to replace them with proper glyphs scaled down glyphs with thicker outlines. I am therefore once more ask for guidance in creating a script that will let me achieve what I posted above.

As for Font Remix Tools, I can’t really see anything there that would be useful there at the moment for my font. The program appears to have been made with sans serif fonts in mind, so I’m not sure how much if any would work in a font such as this.

This is a quickly written skript that should do what you suggested:

suffix = ".sups"
scale = 0.6
offset = 567

glyphName = Layer.parent.name
supsName = glyphName + suffix
supsGlyph = Font.glyphs[supsName]
if supsGlyph is None:
	supsGlyph = GSGlyph()
	supsGlyph.name = supsName
	Font.glyphs.append(supsGlyph)
	print("added", supsGlyph)
for master in Font.masters:
	supsLayer = supsGlyph.layers[master.id]
	component = GSComponent(glyphName)
	component.scale = (scale, scale)
	component.position = (0, offset)
	supsLayer.shapes = [component]
	supsLayer.alignComponents()

Have a look at the “RMX Scaler” it can produce small caps and super/subscript glyphs very easily. You can store presets and remembers previous values when you need to regenerate a glyph (when you changed the outlines of the base glyph).