How to get the file path from a font info window?

How can I get the file path of the glyphs file that belongs to a font info window?

I get the GSTabInTableWindow that is the font info window, and can ask it for its .windowController(), but then I’m lost :wink:

From there, get the document and then its file URL (and then its path, if you need a string).

Hm, I’m observing the active window via NSWindowDidBecomeMainNotification, and sometimes info.object().windowController().document() returns the document, but sometimes it returns None.

getPath: <GSTabInTableWindow: 0x301608d30>
obj.windowController().document(): None

It seems the first time I open the font info, the document is correct, but when I close it and open it a second time, the document is None.

Any idea what how to work around this?

The background for my use case is that I’d like to track how much time I spent on which glyphs file, so I observe the windows and Glyphs itself becoming/resigning active.

It works well for the font window itself, but time spent in the font info window should of course be counted as well :slight_smile:

You might use the Glyphs.currentFontDocument(). That should always give you the GSDocument of the foremost font.