Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

font-patcher: Set SFNT Version #693

Merged
merged 1 commit into from
Dec 12, 2021
Merged

Conversation

Finii
Copy link
Collaborator

@Finii Finii commented Nov 29, 2021

Description

[why]
The Nerd Font Version is not added to the SFNT Version.
This is also a TODO item in font-patcher.
The SFNT-Revision is not updated at all.

[how]
Set the SFNT Version and Revision.

Requirements / Checklist

  • Read the Contributing Guidelines
  • Read or at least glanced at the FAQ
  • Read or at least glanced at the Wiki
  • Scripts execute without error (if necessary):
    • If any of the scripts were modified they have been tested and execute without error, e.g.:
      • ./font-patcher Inconsolata.otf --fontawesome --octicons --pomicons
      • ./gotta-patch-em-all-font-patcher\!.sh Hermit
  • Extended the README and documentation if necessary, e.g. You added a new font please update the table

What does this Pull Request (PR) do?

Set the SFNT Version and let the SFNT Revision be recreated.

How should this be manually tested?

Any background context you can provide?

TODO item in font-patcher

What are the relevant tickets (if any)?

none

Screenshots (if appropriate or helpful)

Here the font is patched first with the origin/master version of font-patcher and afterwards with this MR applied:

image

Note the difference in Revision and the changed SFNT Version string.

query_version is one of several small fontforge helper scripts I use, maybe they should/could be added to bin/ somewhere. I am unsure if this is appropriate.

[why]
The Nerd Font Version is not added to the SFNT Version.
This is also a TODO item in `font-patcher`.
The SFNT-Revision is not updated at all.

[how]
Set the SFNT Version and Revision.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii
Copy link
Collaborator Author

Finii commented Nov 29, 2021

See MS SFNT table description Name ID code 5:
image

@Finii
Copy link
Collaborator Author

Finii commented Nov 29, 2021

$ cat query_version

#!/usr/bin/env python
# coding=utf8

import fontforge
import sys

if len(sys.argv) != 2:
    print("Usage: {} font_name\n".format(sys.argv[0]))
    sys.exit(1)

font = fontforge.open(sys.argv[1])

l = []
for i, el in enumerate(font.sfnt_names):
    l += [(el[1], el[2])]
sfnt = dict(l)

print("Version is          '{}'".format(font.version));
print("CID Version is      '{}'".format(font.cidversion));
print("SFNT Revision is    '{}'".format(font.sfntRevision));
if "Version" in sfnt:
    print("SFNT ['Version'] is '{}'".format(sfnt["Version"]));
else:
    print("SFNT ['Version'] is not set".format(sys.argv[1]));

font.close()

@ryanoasis
Copy link
Owner

query_version is one of several small fontforge helper scripts I use, maybe they should/could be added to bin/ somewhere. I am unsure if this is appropriate.

Totally would be interested, especially in trying to build out more automated checks in github actions workflows.

@ryanoasis
Copy link
Owner

tested a ttf (see the fix) and otf (for sanity). works well.

@ryanoasis ryanoasis merged commit e323f29 into master Dec 12, 2021
@ryanoasis ryanoasis deleted the feature/set-sfnt-version branch December 12, 2021 01:42
LNKLEO pushed a commit to LNKLEO/Nerd that referenced this pull request Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants