Question

I can't figure out how to include a font in my Mac screensaver. I did this following tutorial, Embed font in a mac bundle, but my [NSFont fontWithName:size:] still returns null. I don't really know where to start. Any thoughts, solutions? Thank you

Était-ce utile?

La solution

The example you're following works for an application. The problem is that you're building a screensaver bundle. Those are not applications unto themselves, they are loaded by separate application. Apparently, the ATSApplicationFontsPath key, as its name implies, is only used when loading an application.

You will have to write code to enumerate the font file URLs in your bundle and register them. You can use -[NSBundle URLsForResourcesWithExtension:subdirectory:] and CTFontManagerRegisterFontsForURLs() for that.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top