Show all unused components

I might be missing something obvious, but is there a simple way to show all unused components (to do a cleanup of a font before production)? I am sure it has been discussed before, but I cannot find a script that would do that.

Thanks for any pointers.

What is a unused component?

A component that is part of a font and is not present in any glyphs, i.e. doesn’t have the “Show all glyphs that use this glyph as a component” option when right clicking.

A glyph becomes a component when it is used in another glyph. Your condition is true for almost all glyphs in the font.

Yes, that’s true I suppose.

Well in that case only those “components” that follow the general idea of a component, i.e. named with a preceding underscore and set to Not Export.

Could be done with a little script.

This will give you all glyphs that are not used as components in other glyphs:

usedComponents = []
for g in Font.glyphs:
	for l in g.layers:
		if l.isMasterLayer or l.isSpecialLayer:
			for c in l.components:

unusedComponents = [ for g in Font.glyphs if not in usedComponents]
tabString = "/"+"/".join(unusedComponents)

If you want only glyphs that start with an underscore, change the unusedComponents line to this:

unusedComponents = [ for g in Font.glyphs if"_") and not in usedComponents]
1 Like

Perfect! Works flawlessly. Thank you @mekkablue .