Font Info window and frontmost font

Hi all,

There are many scripts used as part of the production process that always run on the current, or frontmost font. But if the Font Info window has focus (instead of the Glyphs window) they don’t work. Why is this? Is it a bug in Glyphs that Glyphs.font doesn’t return the active font in such cases, or is it by design? And if it’s by design, what is the rationale for this decision, as it’s quite infuriating in such cases.

This might also be related to the following issue, although it seems to have been resolved there:

It works for me. Can you run print(Glyphs.font) with a font info window as frontmost window?

Thanks, Georg. I’ve now looked into it in more detail and the problem arises when more than one font is open. If font A is frontmost and you then click on the font info window of font B, this doesn’t move font B’s window on top of font A’s. So, if you’re working on the font info of font B and execute a script, it ends up getting carried out on font A instead of B.

Is there a better function to return the “current” font? Or could Glyphs.font be modified not to always return the frontmost main window, but also take the Font Info window into account if it is above the others? After all, many scripts are using this function and it doesn’t always behave as expected. Thanks!

I found a good solution. Thanks for pointing that out.