How to generate a static font family from a variable font? (details inside)

Jon PalmiscianoJon Palmisciano Posts: 10
edited December 2020 in Font Technology
Hello everyone. I apologize if this is the wrong place for this post, but I see that many people here are knowledgeable regarding variable fonts and I've been struggling for a couple days to achieve what I am after.

I own a handful of variable fonts, however not all software supports them, and the predefined instances are a little too bold and wide for me. My goal is to be able to generate static cuts from the original variable font with my own axis parameters. This way, I can use the font with all my software, and have complete control over the font's appearance.

For example, I have a variable font ("ExampleVF") with variable width and weight axes. I want to generate the following cuts:
  • ExampleVF Light (wdth=85, wght=250)
  • ExampleVF Regular (wdth=85, wght=350)
  • ExampleVF Medium (wdth=85, wght=450)
  • ExampleVF Semi Bold (wdth=85, wght=550)
  • ExampleVF Bold (wdth=85, wght=650)
  • ExampleVF Extended Light (wdth=110, wght=350)
  • ExampleVF Extended Regular (wdth=110, wght=350)
  • ExampleVF Extended Medium (wdth=110, wght=450)
  • ExampleVF Extended Semi Bold (wdth=110, wght=550)
  • ExampleVF Extended Bold (wdth=110, wght=650)
I first turned to fonttools, but the built in fonttools varLib.instancer can only handle generating the static cuts, and can't rename the fonts so that I can install all of them and have them appear correctly under Microsoft Word, for example.

Is this doable with fonttools? Can anyone suggest how I could achieve this?

I'm a programmer first, type enthusiast second. If someone can simply tell me what tables I need to modify with fonttools, I can do the rest. One thing I did notice is that fonttools exports TTFs, which as far as I understand have a limited number of subfamilies on Windows, so I'm not sure if I also need to add OTF into the mix somewhere.

Sorry for the long post. I would really appreciate some advice on this. If someone can point me in the right direction, I will report back here once I've written the program and publish it on GitHub!

Comments

  • Viktor RubenkoViktor Rubenko Posts: 119
    edited December 2020
    Generate static, then edit 'name' table with fontTools. 
    MS Word supports 4 styles per font: regular, bold, italic and bold italic. So if you have more styles, you should split it into subfamilies. Also you may need to modify fsSelection for Bold/Italic styles.
  • Jon PalmiscianoJon Palmisciano Posts: 10
    edited December 2020
    Generate static, then edit 'name' table with fontTools. 
    MS Word supports 4 styles per font: regular, bold, italic and bold italic. So if you have more styles, you should split it into subfamilies. Also you may need to modify fsSelection for Bold/Italic styles.
    Thank you very much for your response Viktor. I will try this and share my results.
  • Jon PalmiscianoJon Palmisciano Posts: 10
    edited December 2020
    Generate static, then edit 'name' table with fontTools. 
    MS Word supports 4 styles per font: regular, bold, italic and bold italic. So if you have more styles, you should split it into subfamilies. Also you may need to modify fsSelection for Bold/Italic styles.
    Hi Viktor. I have written a program to create the static instances and save them with the modified name tables in accordance with the Microsoft OpenType specification. However, this still didn't as expected. Many programs failed to recognize the font correctly, including Windows itself.

    The input to my program is a variable font in TTF format, and the output is static TTFs. Converting these static TTFs to OTFs via an online tool, then installing them makes them work as expected.

    Is there a way I can export as OTF from fonttools? I have searched around but cannot find any answers. Is there a workaround to make the TTF format work?
  • Probably, this online tool makes some modifications, that you did not through your script.
    Try to export them to ttx and compare tables data.
  • Probably, this online tool makes some modifications, that you did not through your script.
    Try to export them to ttx and compare tables data.
    I converted to TTX and compared. There were no differences in the name table, and only xAvgCharWidth and usFirstCharIndex differed in the OS/2 table.

    Despite this, when I install the TTFs I generated, they look like this in Windows settings, clearly indicating something is wrong:


    When I convert to OTF and then install, it looks as you would expect, with different names and weights.

    Is there any way I can convert from TTF to OTF inside of fonttools? It seems like that could be the solution.
  • Viktor RubenkoViktor Rubenko Posts: 119
    edited December 2020
    Did you tried to convert your ttfs to new ttfs with online tool? I am sure, that they will work too. 
  • Did you tried to convert your ttfs to new ttfs with online tool? I am sure, that they will work too. 
    Using the FontForge Python package to simply load my produced TTF and save it with a different name seems to solve the issue. I can't spot any changes in the name table between the two versions and don't understand why it works, but at least it works.
  • For anyone who might stumble upon this in the future, if you are interested in a program that can instantiate fonts and tweak names, etc. too, you can check out my project, VFIT, here.
  • Can you provide some sample files that aren't working and the ones that are? 
  • Can you provide some sample files that aren't working and the ones that are? 
    See my message above. I found a temporary workaround and then Viktor submitted a pull request with the proper fix. All is in order now!
  • Well done indeed! A few thoughts on this since I've been working on something similar:
    • it would be nice to provide implicit defaults, so no config is needed, or
    • provide only a desired font family and axis values via CLI options
    • you can use an existing STAT table to deduct at least a partial name—it won't be unique "enough" but could work for the above in conjunction with the selected axis values
    For anybody wondering, apart from the name table updates, the couple of relevant code sample lines for doing this with fontTools are in the documentation.
  • Well done indeed! A few thoughts on this since I've been working on something similar:
    • it would be nice to provide implicit defaults, so no config is needed, or
    • provide only a desired font family and axis values via CLI options
    • you can use an existing STAT table to deduct at least a partial name—it won't be unique "enough" but could work for the above in conjunction with the selected axis values
    For anybody wondering, apart from the name table updates, the couple of relevant code sample lines for doing this with fontTools are in the documentation.
    Thanks!

    I'll definitely think about expanding the configuration system or adding defaults in the future. I'm content with where the program is at right now for my use case at least. As far as I am aware, there are no other users, but if others are interested in the program and desire more features, I would happily consider adding them.

    For you or anyone who is reading this in the future, feel free to open a GitHub issue for a feature request.
Sign In or Register to comment.