18

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.

reojased
  • 709
  • 1
  • 7
  • 19
  • I know the question has been answered, but I would like to share this resource with you. Make sure the font you use is permitted for commercial use in the license: http://www.dafont.com – TheCodeComposer Aug 18 '15 at 03:27
  • Possible duplicate of [Swift Custom Fonts Xcode 7](https://stackoverflow.com/questions/31420758/swift-custom-fonts-xcode-7) – Tamás Sengel Nov 18 '18 at 14:55

3 Answers3

42

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)
Hemang
  • 26,840
  • 19
  • 119
  • 186
bpolat
  • 3,879
  • 20
  • 26
17
  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

Devapploper
  • 6,062
  • 3
  • 20
  • 41
2

i would like to add this code if you know your font family name (which you can see in the fontPicker in the IterfaceBuilder) use this to apply the font programatically

func apply_font(FontFamilyName:String)
{
  label.font = UIFont(name: UIFont.fontNames(forFamilyName: 
  **FontFamilyName**)[0], size: 15)
}
Mohamed Hashem
  • 146
  • 2
  • 2