SOLVED Can I set os/2 font info (or other OpenType info) in script?



  • TL;DR: the answer to my question is the spec at http://unifiedfontobject.org/versions/ufo3/fontinfo.plist/


    It's very simple to set basic font info through script:

    # Update the family name of the current font
    CurrentFont().info.familyName = "New Family Name"
    

    This is great, as it allows me to efficiently update font info across many fonts, like this:

    from vanilla.dialogs import *
    inputFonts = getFile("select UFOs", allowsMultipleSelection=True, fileTypes=["ufo"])
    
    for fontPath in inputFonts:
        f = OpenFont(fontPath, showInterface=False)
        f.info.familyName = "New Family Name"
        f.save()
        f.close()
    

    However, I'm struggling to set OS/2 info in fonts. My expectation is that something like f.info.achVendID = "ARRW" or f.info.OS_2.achVendID = "ARRW" or f.info.openTypeOS2AchVendID would work, but they're not.

    This will be even more important for me to set the vertical metrics (usWinAscent, typoDescent, etc) how I want to across many fonts.

    Ultimately, I hope to create one script that sets any font info across many masters (24+). Beyond help(f.info), which only gives partial insight, how can I learn the methods to set arbitrary font info?


    UPDATE: Just before I submitted this, I found the UFO3 spec, which is just the master list I was hoping for. So, my question is solved, but I'll post this anyway, so it's easier for the next person (possibly myself in the future) to find.

    I can set the vendor ID like this:

    f.info.openTypeOS2VendorID = "ARRW"
    

    And I can set the Hhea Descender like this:

    f.info.openTypeHheaDescender = -350
    


  • @ThunderNixon aw:) 💅



  • Connor, I love you.

    80d8728b-fe67-4a62-935c-1e8814eca429-image.png



  • Amazing; two great replies! Thanks so much :)


  • admin

    cool!!!!!



  • This is why I made these, no more remembering long font.info attributes:)


  • admin

    the spec is the place to learn about font.info attributes, also it describes where the values go to while generating a binary.

    programmatically you can get all ufo3 font info attributes with:

    f = CurrentFont()
    
    print(f.info.fontInfoAttributesVersion3)
    

Log in to reply