Reading a .glyphs File with PHP

Hi guys,

I’m working on a project where I need to read and parse .glyphs files using PHP.

Can you give any tips on how to achieve this? For example parse glyphs file to json…

Best,
Michał

Why PHP? Most webspace support python (at least the few I have worked with do).

Check if you can find a plist parser. But you will need a bunch of extra code to write the file as the there are some small format adjustments to make the file smaller and easier to read. Glyphs can read a file written by a default plist writer but it will create a lot noise in the file.

What exactly are you trying to do with the file. Maybe it is easier to do it my manipulating the text content directly?

I’ve written a PHP parser for OpenStep-flavor property list files, which is what .glyphs files are (the “container format” that Glyphs files use). You can find the source code here:

Thus far, I have only used this code in specific scenarios, meaning there might very well be files for which this code does not work. If so, let me know; it’s probably an easy fix.

1 Like

Ohh. Don’t give me more ideas to play with :face_with_peeking_eye:

2 Likes

I would like to upload a .glyphs file to my website and automatically extract some data from it.

In the first scenario, I want to extract only the names and instances.

In the second scenario, I would like to generate various font formats like OTF and WOFF. To accomplish this, I need to install the glyphsLib Python library on the server, correct?

Thanks, but unfortunately, it throws an Exception: UnknownSpecialCharacter.

I need to build a feature for each scenario, so I believe I need to proceed with Python…

To extract info, the PHP parser form Florian can help. But to generate an instance you need glyphsLib and python anyway. So you might as well do the info extraction in python, too.

2 Likes

For Python, there is openstep-plist (and if you use glyphsLib directly, you don’t need a plist parser anyway). Otherwise, I changed the PHP code to handle a few more special characters, so it should work now.

2 Likes

Thanks guys! I have installed glyphsLib and got what I needed. :smiley:

You might try the Glyphs3-merge branch. It can handle Glyphs3 files much better.

Ok, I will do. Can I generate OTFs and WOFFs with this library on the server?

Have a look at fontmake.

Thanks, I successfully generated OTF and WOFF2 files using Fontmake and Fonttools. However, I noticed that the WOFF2 file produced by Glyphs is slightly larger (33KB) than the one (26KB) generated by Fonttools (converted from the OTF file created by Fontmake).

Are they as good as those generated by Glyphs? Should I be carefull with them?

Can you compare the size of the .otf? And also composer the individual table sizes (you can do that in OTMaster)

The OTF file from Glyphs is also slightly larger at 57KB compared to the 46KB file from Fontmake.

I suspect that fontmake is exporting less mark positioning. So the size of the GPOS table would be different.

This looks promising GitHub - googlefonts/fontc: Where in we pursue oxidizing (context: https://github.com/googlefonts/oxidize) fontmake.
I’m curious to see how it develops. I ran some tests, and it generates VF files incredibly fast.

Unfortunately, both Fontmake and FontC crash when processing .glyphs files with smart components.

Can you suggest how to deal with smart components?

It seems that they are working on it. It might help if you provide them with test files.