Get .glyphs file without opening it in App

I need to get some Information (basically the glyphs) from a certain .glyphs file into another script. actually opens the file in the App, which is not what i want. Instead i’d like to instantiate it and work with the instance as a virtual GSFont. Is that possible?

My goal is to draw glyphs from a font that cannot be installed at the users computer, so I want to supply the .glyphs file in the script’s resources folder.

Did you try

font = GSFont("Path to file")

Now I did. Doesn’t work. the font object is a new, empty font:
<GSFont "new Font" v1.0 with 1 masters and 0 instances>
The to-import font has an instance and glyphs, though.

I tried to call the font itself, laying next to the script, as well as getting the direct dir via
parentFolderDir = os.path.abspath(__file__)[:-3] font = GSFont("%s/myFont.glyphs" % parentFolderDir)

So I bet the dir pah to file has to be set differently?!

Sorry for bumping. But any news on this? font = GSFont("Path to file") doesn’t work.

You need to supply a full, absolute path.

I did. I printed a full path via print Glyphs.font.filepath and used that as the file path. No success.


import os
absolutePathOfcurrentFont = Glyphs.font.filepath
print GSFont( os.path.abspath(absolutePathOfcurrentFont) )
print GSFont( absolutePathOfcurrentFont )
1 Like

You are right. I fixed it.
But you could also use this:"Path to file", showInterface = False)

Thank you so much! I am glad, it works nicely indeed.