fontforge / fontforge

Free (libre) font editor for Windows, Mac OS X and GNU+Linux
http://fontforge.github.io/
Other
6.33k stars 694 forks source link

Set fullname and fontname via Python with detached Postscript attributes #3275

Closed ChristinWhite closed 6 years ago

ChristinWhite commented 6 years ago

Important

Mark with [x] to select. Leave as [ ] to unselect.

When reporting a bug/issue:

I'm not sure if there is an actual issue or whether I'm simply missing something, I'm definitely not font format expert.

I'm using a fork of Ligaturizer to add the programming ligatures from FiraCode to other fonts via a Python script and, my tweak, to change the font name in the process.

Generating the ligatures works fine but I'm having trouble setting the full name and family name on SF Mono.

The relevant portions of the code are:

def change_font_names(font, fontname, fullname, familyname, copyright_add, unique_id):
    font.fontname = fontname
    font.fullname = fullname
    font.familyname = familyname
    font.copyright += copyright_add
    font.sfnt_names = tuple(
        (row[0], 'UniqueID', unique_id) if row[1] == 'UniqueID' else row
        for row in font.sfnt_names
    )

This works fine with most of the fonts I've tried, but on SF Mono only the fontname (and possibly sfnt_names) are being respected, it doesn't matter what I put in the fullname and familyname parameters, they are never used.

I believe this is due to the TTF names table attributes being detached from the postscript names in this particular font, if I attach them in the UI and generate the font the script works as expected but I'd like to ensure that the script can handle this situation if possible.

Can I pass a TTF equivalent of fullname and familyname via the script or is it possible to programmatically flag attach the postscript for those attributes?

I have tried manipulating the cidfamilyname and cidfullname as well as trying appendSFNTName but given that neither makes a difference I'm guessing those are different types of metadata.

Thanks!

Version: 19:05 UTC 30-Jul-2017 OS: macOS High Sierra 10.13.3 (17D102)

frank-trampe commented 6 years ago

So, just to be clear, you're importing FiraCode in OTF, setting fullname and familyname, exporting back to OTF, and finding that fields 1 and 4 in the name table do not match those values?

ChristinWhite commented 6 years ago

Sorry for the slow reply Frank, this fell off my radar and probably isn't something I'm going to work on anytime soon, if I have a chance to revisit it in the future, review what I was doing exactly and still run into the same issue I'll open another issue. Thanks!