Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using custom fonts in Xcode 6 - Swift [duplicate]

Tags:

swift

I'm new to Swift! I'd like to know how I can use custom fonts in my swift application in Xcode 6.

like image 626
Milese3 Avatar asked Aug 13 '14 15:08

Milese3


1 Answers

You just drag the font file (.ttf) into the resources area on the left pane of Xcode.

When you drop it in, a dialog box will appear. Make sure the target for your application checkbox is checked. Then add the following key to your plist:

Fonts provided by application

With the values of the filename "myFont.ttf"


UPDATE (see comment below)

Also make sure the font is added to the Copy Bundle Resources (found under Target -> Build Phases) I just spent about an hour on this, and I was the one who answered this question months ago lol.


UPDATE

Another helpful tip to find the name of the font for the font-family if you are using CSS is to run the following command:

NSLog("Available fonts: %@", UIFont.familyNames());

It prints out all the font name available to the system, including the ones you custom added.

like image 120
quemeful Avatar answered Sep 19 '22 19:09

quemeful