Help needed to create json files [SOLVED]

Could someone knowledgeable be so kind and give a step by step tutorial with precise syntax on how to use the R. Piechaud Python script to create a json file for metadata for a smufl font?
I tried all kind of things but failed miserably because I do not know the basics to deal with Python scripts.
I just know that one need FontForge, the Piechaud script and a Smufl font.
But how to run the script and how to use and connect these three parts is absolutely not clear to me.

In the long run I would like to be able to convert several music fonts I own to into smufl fonts.
I have read quite a lot of threads on this and I am aware that it is quite a lot of work, but well I want to begin and the first thing I would like to do is to be able to create the necessary json file.

Interesting topic, I will follow it !

@ MarcLarcher
I am glad that you are interested too!

Searching further I had a look to the script in PSPad (a text editor).
Among other things I could read this:

The script must be invoked from within the font’s directory

I then did this:

  1. Put a .ttf file (the smufl font) and the python script in the same directory
  2. Right click on the script, choose the option “Open with”, search for the program “FontForgeBuilds/bin/fontforge.exe” and then press OK
  3. Something happened and the dos windows opened fast and closed as fast as it opened, I could not read what has been done and I do not know if something has been generated and if yes where it is.

Any help would be really welcome.

I also did this:

  1. Open FontForge and load the ttf file of the Smufl font
  2. Choose “Execute Script” in the File menu: a window (editor-like) opens
  3. Copy the script in this editor-like window
  4. Press OK

Nothing happens or if something happens I do not know what.

Not sure if anyone is interested in my groping around in the dark but maybe it can prevent someone as unknowledgeable as I am not to do this :wink:

Out of curiosity and to get some kind of “result” I simply made a copy of the existing json file from another smufl font.
I just renamed the file accordingly and also renamed the font in the declaration of the json file.
At least Dorico could open and recognised the new font and I was able to choose the new font in the “Change Fonts” window.
Selecting the new font I unchecked the option “Use font’s recommended engraving options” because when the option is active I obtain strange results!
But with this option unchecked it seems as if Dorico is then able to use quite a lot of elements of the new font.
I could recognise that the design of keys, accidents, rests and so on had changed.
This is surely not the way smufl fonts have to be used but at least I could see some changes!

I would still be happy for any kind of help.

I just created my first json file from scratch :wink:

As written in the SMuFl specification ( only the “fontName” and the “fontVersion” are mandatory for the metadata file.
Writing the following four lines in a text editor and saving them as “myfont.json” will work as a so to say default or empty metadata file for the font “myfont”. At least it will allow Dorico to recognize the font.

“fontName”: “myfont”,
“fontVersion”: 1.0

Of course “myfont” must be installed as any other font and the json file must be in the right folder at the right place.

I now must learn to understand what all the Metadata do for the font and what is the difference between an empty json file and one with all metadata.
And I still was not able to run the R. Piechaud script.

BTW I now realized that the Bravura json file contains 32152 lines of code for the “glyphBBoxes” metadata and as far as I understand these metadata are only for Finale and they are of no use for Dorico!
Considering that the whole Bravura json file has 43481 lines I find it quite amazing:
32152 lines for Finale and 11329 for Dorico!

For the sake of completeness I write down the last results.

Abraham Lee from Music Type Foundry was so kind to help me.
He gave me a comprehensive step by step explanation on how to use the Robert Piechaud script.
Before I write the steps down here are the necessary things you must do before you can run the script.

. Install FontForge on your system.
You can find the last version of FontForge here:

. Download Robert Piechaud’s script.
You can find it here:
You will have to copy the whole code in a text editor and save it as: “”

. Create your own SMuFl font or find a SMuFl font that does not have a json file.

Here are the steps:

  1. After you created your font save the FontForge SFD file, preferably with a name that does not have any spaces in it.
    If you have an existing SMuFL font, load it first in FontForge and proceed as described above.

  2. Put Robert’s script in the same directory as the SFD font file because that makes the command line stuff a little easier.
    Edit: create also a folder named “json” in this directory!

  3. Open up a command prompt and navigate to the directory that contains the SFD file (I’ll call it myfont.sfd below, but you use whatever name you want to call the SFD file) and Robert’s script, then execute the following command:

“C:\Program Files (x86)\FontForgeBuilds\bin\ffpython.exe” myfont.sfd

This runs a specially compiled version of Python that has access to FontForge’s functions, which executes Robert’s script, which requires you to specify the font file that it is creating the JSON file for. Once run, you should have two new files in the directory, one for SMuFL called “myfont_metadata.json” and another for LilyPond called “” (which is unnecessary for what we’re doing, so you can discard it). You will need to rename the JSON file to be just myfont.json since the SMuFL spec recently changed for how the file should be named.

Edit: Have a look at the created json file and take care that the first three lines are written correctly!
They should be:

“fontName”: “myfont”,
“fontVersion”: 1.0,
_4. Now, generate the font binary by going to File > Generate Fonts then choosing the “OpenType (CFF)” output type, setting the name to “myfont.otf” and hitting “Generate”

  1. Install the font like normal in C:\Windows\Fonts and put the JSON file in C:\Program Files\Common Files\SMuFL\Fonts\Fonts\myfont.

    I am glad to now know how one has to proceed.

    (Edit: the following problem has now be solved, see the next two posts)
    Following these steps I was able to run the script, unfortunately on my system I encounter some problem running the script.
    I get the following IO error:

    Traceback (most recent call last):
    File “”, line 70, in
    log = open( outDir+fontName.lower()+’.log’, ‘w+’ )
    IOError: [Errno 2] No such file or directory: ‘json/myfont.log’
    As I know nothing about Python I am not able to solve this on my own.
    I suspect either there is something one should change in the script (for example I do not know what this sentence from Abraham Lee means when he writes: “… which executes Robert’s script, which requires you to specify the font file that it is creating the JSON file for.”
    It can also be that this is a problem with the right paths or possibly also a folder-rights thing.

    I will search further but for the moment who knows, maybe these informations may already help someone else.

    Edit 1: I added two necessary apostrophs in the code line for the command prompt!
    Edit 2: Thanks to Paul the problem mentioned above has been solved, it is necessary to also create a folder named “json” within the directory where the script and the sfd file are!
    Edit 3: I added a correction in step 3, it can be necessary that the first three lines of the json file have to be corrected._

This looks to be a problem with the path. It can’t find the output directory called ‘json’. This suggests to me that either you need to set the absolute path, and if you are on Windows then you can’t use the backslash in paths directly, you need to use the ‘raw’ string format, so set it as r’c:\path\to\json’ (note the ‘r’ prefix). The other related possibility is that you have to run the script from a specific directory. Lastly, ensure that the ‘json’ directory actually exists.

Thanks a lot Paul for your contribution.
Something is working now and at least the script creates now a json file.
I only had to create indeed the folder “json”!
In the script the code line 52 says:
outDir = ‘json/’;

I had no folder with this name.
I created this “json” folder within the folder where the script and the sfd are and now it works :slight_smile:
Now I get a json file in this folder.
I edit my previous post accordingly.

But unfortunately now Dorico does not accept this file and I get the following error from Dorico:
Error opening file: invalid file format
C:/Program Files/Common Files/SMuFL/Fonts/myfont/myfont.json

One problem is solved and the next one is already here :slight_smile:

It works now :slight_smile:
I had a look at the created json file and for some reason the mandatory three lines that I mentioned in post 5 of this thread were not written correctly!
After correcting these three lines everything is working as it should.
I will then add this to the step by step explanation.