Re: Fonts in Projects
Re: Fonts in Projects
- Subject: Re: Fonts in Projects
- From: Darrin Cardani <email@hidden>
- Date: Thu, 28 Sep 2017 14:19:49 -0700
Fred,
I’m not entirely sure I understand all your needs here. If you just need the
font for your own plug-in, you can load it from your plug-in’s bundle in its
Fonts directory like this:
> NSBundle *bundle = [NSBundle bundleWithIdentifier:
> @"com.apple.motion.TextFramework"];
> NSArray *fontPaths = [bundle pathsForResourcesOfType:nil
> inDirectory:@"Fonts"];
> for (NSString *fontPath in fontPaths)
> {
> CFURLRef url = CFURLCreateWithFileSystemPath(NULL,
> (CFStringRef)fontPath,
> kCFURLPOSIXPathStyle,
> false);
> if (url)
> {
> CFErrorRef error = NULL;
> bool succ = CTFontManagerRegisterFontsForURL(url,
> kCTFontManagerScopeProcess, &error);
>
> if (!succ)
> {
> //Handle the error here
> }
> CFRelease(url);
> }
> }
That’s the code we use to load custom fonts from Motion’s TextFramework bundle
that lives inside the app. (You’ll obviously want to load from your own bundle,
not from Motion's TextFramework bundle.)
I’m not sure what the implications would be if the plug-in was loaded
out-of-process, as we hope to be able to do one day. If you’re just using the
fonts for rendering, I think that would be fine. But if the user wants to be
able to use the fonts in other ways within the app, they won’t show up in the
app’s UI if the plug-in is out-of-process. But of course, that’s not how it
works today, so probably not a problem for the near term.
Darrin
> On Sep 28, 2017, at 12:56 PM, email@hidden wrote:
>
> I'm curious as to the recommended method of including fonts with a
> pluging (especially one that's Motion only). Having an installer install
> to the user directory's font directory can sometimes pose issues if it's
> installed somewhere else like the system font directory. Do you
> recommend compiling a .app just to provide the fonts? Thanks for any
> suggestions!
>
> Fred
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Pro-apps-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden