rghome
rghome

Reputation: 8831

How (or if) to use the Skia (or any unknown) font in an iOS app

I am designing an iOS (SpriteKit) app and have found the Skia (substitute this for any unknown font) font in the list of available fonts in the font-picker if I add an SKLabelNode to the scene. However, when I run the app in the simulator a substitute font appears.

As far as I know, this font came with Xcode. I certainly didn't buy it, although it could have come as part of another application.

Using a font like Chalkduster seems to work OK and does not require an additional work.

So I am wondering if this font requires any special actions to get it to be recognised (e.g., is it like a custom font) or is there some other issue.

Furthermore, if this isn't a standard Xcode font, could I get to get in to trouble for using it in a commercial app?

EDIT: it would be appreciated if answers could state (a) whether this font is visible in their version of Xcode and (b) whether it works.

EDIT2: OK, so a bit more research. I downloaded and installed a real (free) custom font and this now appears in the font-picker, but it is not actually rendered by my app.

So it appears that Xcode shows all fonts installed on the system, whether they are accessible by your app/target device or not. However, you can only use it by following the procedures described in the answers below. This is probably a good thing as it would stop you using accidentally using a font that you have acquired and for which perhaps you don't have the licence. But is a bit annoying that fonts you can't use are offered in the font-picker.

Upvotes: 0

Views: 921

Answers (3)

matt
matt

Reputation: 535304

So I am still wondering why I can see it in the Xcode font picker

Xcode is running on your computer. Once you choose Custom as the Font pop-up selection for an interface object in Interface Builder (such as a UILabel or, as you have discovered, an SKLabelNode), the Family pop-up shows all the fonts on your computer.

Upvotes: 0

sangony
sangony

Reputation: 11696

Skia is not part of the fonts included with iOS. You can get a list of all preinstalled iOS fonts from iosfonts.com or wptechonlogy.com

You can list all installed fonts on your device by doing this:

NSArray *fontFamilies = [UIFont familyNames];

for (int i = 0; i < [fontFamilies count]; i++) {
    NSString *fontFamily = [fontFamilies objectAtIndex:i];
    NSArray *fontNames = [UIFont fontNamesForFamilyName:[fontFamilies objectAtIndex:i]];
    NSLog (@"%@: %@", fontFamily, fontNames);
}

(source for above code)

To install a font, you can either use an app like iOS Font Maker or use code to do it yourself. The steps involved are:

  1. Include your fonts in your Xcode project.
  2. Make sure that they’re included in the target.
  3. Check that your fonts are included as Resources in your bundle.
  4. Include your iOS custom fonts in your application plist.
  5. Use UIFont and specify the name of the font.

Codewithchris.com has a step by step tutorial on how to add a custom font.

Upvotes: 2

giorashc
giorashc

Reputation: 13713

Regarding your last question, yes. If the font is not provided as part of the iOS fonts you will have to obtain its license (some are free but some are not so make sure to be on the safe side).

Check this license page for Skia

Upvotes: 2

Related Questions