0

I know, if I want to use a font, that already exists in system, I can set it, for example, this way (1):

[[_someButton cell] setFont:[NSFont fontWithName:@"SomeAlreadyInstalledFontName" size:s]];

I also know, I can use a custom font from my project resources someway like that (2):

NSFont* someCustomFont = (NSFont*)[fontConverter fontFromBundle:@"SomeCustomFontName" withHeight:someHeight];

[[_someButton cell] setFont:someCustomFont(12)];

fontConverter is my class, that has a method with this signature:

- (CTFontRef) fontFromBundle : (NSString*) fontName withHeight : (CGFloat) height;

It works, however I want, instead of using method (2), install my custom font to system and work with it like (1).

So is it possible to do this: check, if custom font is installed in system, if no, then install it, when the application is launched/being installed?

Olter
  • 1,129
  • 1
  • 21
  • 40
  • You just have to copy the font file to `/Library/Fonts`. Of course, you need permissions/entitlements. – Nikolai Ruhe Mar 18 '15 at 08:09
  • Do you need your font to be available to *other* apps? Or do you just want to make it somewhat more automatic for your app to find its own fonts? – Ken Thomases Mar 18 '15 at 09:26
  • I want the same thing for my mac app. Did you find any proper solution? Please post if you are done with it. – Manthan Jul 03 '15 at 07:06

1 Answers1

1

File > Add Files to "Your Project Name"

then move your file to supporting files and be sure that you selected right target for your app and check that following paths:

Select your project from project navigator> Build Phases> Copy Bundle Resources

if your font appears there it means you did everything correct. The last step is add your font to .plist file:

Select your info.plist add an array Fonts provided by application and add your font in it as a string

It worked in my case and hope it will help you, too. For further information you may examine this: Adding custom fonts

miletliyusuf
  • 982
  • 1
  • 10
  • 12