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

Bug fix for #757 - write all name table entries for fonts crafted from scratch #758

Merged
merged 2 commits into from
Sep 9, 2024

Conversation

mattlag
Copy link
Contributor

@mattlag mattlag commented Aug 29, 2024

Description

Due to a change in 858a5d2, fonts that are created from scratch are not generating two default name table entries, which is causing fonts to be un-openable in Windows.

Lots of details captured in #757 - but here is a quick overview of the bug. The bug that was causing issues for two reasons:

  1. the for... in loop is looping over the keys of the array, 0, 1, 2 as opposed to the values of the array (which looks like what was intended).
  2. If an empty value is found, the unicode value is updated as opposed to whatever platform is currently being looped over.

Motivation and Context

Any font object generated programmatically would successfully export, but the font file itself would not be able to be opened. In Windows the "This is not a valid font file" dialog would be shown.

How Has This Been Tested?

Lots of tests explained in #757

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I did npm run test and all tests passed green (including code styling checks).
  • I have added tests to cover my changes.
  • My change requires a change to the documentation.
  • I have updated the README accordingly.
  • I have read the Contribute README section.

 - `for...in` loop iterates over keys in `names` object, not indexes of an array of strings
 - if `uniqueID` or `postScriptName` is found to be missing, update the platform that is currently being looped over, not just the `unicode` platform.
Test now checks for defaults for `postScriptName` and also `uniqueID`

Generating a `uniqueID` now provides a fallback empty string if no `manufacturer` exists.
Copy link
Contributor

@Connum Connum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

@Connum Connum merged commit f8108ec into opentypejs:master Sep 9, 2024
1 check passed
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.

Fonts crafted from scratch always result in "not a valid font file" on Windows
2 participants