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: Fix behavior when trying to patch non-font files #1648

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

Finii
Copy link
Collaborator

@Finii Finii commented Jun 2, 2024

[why]
When the file specified to be patched is not a font file the patcher run errors out with an out of index runtime error:

Traceback (most recent call last):
  File "/home/fini/extra/git/nerd-fonts/font-patcher", line 2155, in <module>
    main()
  File "/home/fini/extra/git/nerd-fonts/font-patcher", line 2147, in main
    patcher.generate(sourceFonts)
  File "/home/fini/extra/git/nerd-fonts/font-patcher", line 415, in generate
    sourceFont = sourceFonts[0]
                 ~~~~~~~~~~~^^^
IndexError: list index out of range

[how]
Do not assume that the specified file will be a font file but rather check if fontforge detects a font in the file and error out if there is no font found.

Fixes: #1647

Reported-by: Kristopher James Kent kris@kjkent.dev

Requirements / Checklist

  • Read the Contributing Guidelines
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan.
    Issue number where discussion took place: #xxx
  • If this contains a font/glyph add its origin as background info below (e.g. URL)
  • Verified the license of any newly added font, glyph, or glyph set. License is: xxx

What does this Pull Request (PR) do?

Prevent a runtime error in certain situations and instead prints an understandable explanation why processing can not continue.

How should this be manually tested?

Any background context you can provide?

What are the relevant tickets (if any)?

Screenshots (if appropriate or helpful)

@Finii Finii added the Bug fix label Jun 2, 2024
@Finii
Copy link
Collaborator Author

Finii commented Jun 2, 2024

Screenshot from 2024-06-02 08-21-38

[why]
When the file specified to be patched is not a font file the patcher run
errors out with an out of index runtime error:

Traceback (most recent call last):
  File "/home/fini/extra/git/nerd-fonts/font-patcher", line 2155, in <module>
    main()
  File "/home/fini/extra/git/nerd-fonts/font-patcher", line 2147, in main
    patcher.generate(sourceFonts)
  File "/home/fini/extra/git/nerd-fonts/font-patcher", line 415, in generate
    sourceFont = sourceFonts[0]
                 ~~~~~~~~~~~^^^
IndexError: list index out of range

[how]
Do not assume that the specified file will be a font file but rather
check if fontforge detects a font in the file and error out if there is
no font found.

Fixes: #1647

Reported-by: Kristopher James Kent <kris@kjkent.dev>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii Finii force-pushed the bugfix/no-font-in-file branch from e7f6a4f to c8f68dc Compare June 2, 2024 06:48
@Finii Finii merged commit b95c671 into master Jun 2, 2024
4 checks passed
@Finii Finii deleted the bugfix/no-font-in-file branch June 2, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker nerdfonts-patcher errors out on fontforge start
1 participant