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

OS X null pointer crash on font missing family attribute #20

Closed
lynaghk opened this issue Jul 25, 2017 · 7 comments
Closed

OS X null pointer crash on font missing family attribute #20

lynaghk opened this issue Jul 25, 2017 · 7 comments

Comments

@lynaghk
Copy link

lynaghk commented Jul 25, 2017

Thanks for this and for fontkit, both are great libraries!

One of our designers ran into a crash on OS X that we tracked down to a font that was missing a "family" attribute.
Specifically, this line, where CTFontDescriptorCopyAttribute returns null, which eventually blows up when the resulting FontDescriptor gets coerced to JavaScript world.

Options for a fix seem to be:

  1. Checking the string attributes for null and falling back to a default (e.g., "No Family Detected"), or

  2. Ignoring fonts that have missing attributes. The approach I'd take on this is to allow createFontDescriptor to return null if the font is busted, and explicitly handle this null in the places where it's called (getAvailableFonts, findFonts, and substituteFont).

The reasoning for the second option is that a font that's missing a family is probably broken in other ways.
(Suitcase Fusion 6 describes the font that crashed font-manager as "corrupted".)

Happy to submit an OS X patch for whatever resolution you prefer.
(Would also be happy if you want to just code it up yourself.)

Thanks again for the great libraries!

@implausible
Copy link
Contributor

@lynaghk You wouldn't happen to have the font that caused your crashes hanging around, would you?

@lynaghk
Copy link
Author

lynaghk commented Sep 14, 2018

I do not, sorry. The font was from a client and I didn't save a copy after we resolved the issue on our own fork of this library. For what it's worth, the font was frutiger65_bold.ttf, though I have no idea where it was purchased/downloaded, etc.

@fahrio
Copy link

fahrio commented Dec 7, 2018

@implausible I just stumbled upon this issue when I installed a web font with a problematic 'name' table structure. I am attaching the font (it's a "trial" font) if you are still interested.
3825B1_0_0.ttf.zip

@lynaghk The font that is causing the crash is a web font and was not intended to be installed on the OS. It falls into your 2. category and can be ignored. I am building an app with this library, would you be able to share your patch or how to modify the library to ignore these "corrupt" fonts?

@implausible
Copy link
Contributor

@fahrio Check out https://www.npmjs.com/package/font-scanner. It's a fork of this package with a few fixes we discovered when deploying this library in GitKraken.

@devongovett
Copy link
Member

Should be fixed by #35.

@implausible if there are other fixes you guys made in your fork, we'd love for you to contribute them back!

@devongovett
Copy link
Member

@implausible also, if you'd like to be a maintainer of font-manager itself, I'd add you to the repo.

@implausible
Copy link
Contributor

@devongovett I'd definitely take you up on that. We've gotta fix the Electron issue #42

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

No branches or pull requests

4 participants