Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use custom font in swift [closed]

Tags:

swift

fonts

I need a font for swift sprite kit, iOS. this font is for commercial purposes and im trying to have a kind of arcade font. I would want to create my own font, or to get a public font which i can use for commercial purposes, and how do I install this font, how do I implement it on swift. Thank you.

like image 214
reojased Avatar asked Aug 17 '15 21:08

reojased


People also ask

How do I change the font style in Swift?

To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.


2 Answers

Fist make sure that your font is .ttf or .otf format

  1. Import your font into the project
  2. Add new key "Fonts provided by application" on application's info.plist file and add your font names Now you can use custom fonts with interface builder or programatically

enter image description here

yourLabel.font = UIFont.init(name: YourFont, size: size)
like image 79
bpolat Avatar answered Oct 24 '22 05:10

bpolat


  1. First of all you need to drag the font into the project.
  2. After that you need to select the font and select the target Membership checkmark for your app as seen in the picture.

Xcode window with selected target membership for the custom font

  1. After that you go to your Info.plist and add the Name of the font in "Fonts Provided By Application"

  2. Now you can finally use the font als you would use every other font. If it doesn't work as ir should you can find out the name Xcode gave the font with

    for name in UIFont.familyNames() {
      println(name)
      if let nameString = name as? String
    
    {
    
        println(UIFont.fontNamesForFamilyName(nameString))
      }
    }
    

UPDATE

The Font is called Fipps-Regular and 100% free to use Download here

like image 17
Devapploper Avatar answered Oct 24 '22 04:10

Devapploper