Use custom font in swift

I need a font to quickly set iOS sprites. this font is for commercial use and I'm trying to create some kind of arcade font. I would like to create my own font or get a public font that I can use for commercial purposes, and how to install this font, how to implement it on a fast one. Thanks.

+6
source share
4 answers

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

  • Import your font into the project
  • Add a new key "Fonts provided by the application" in the application info.plist file and add font names. Now you can use custom fonts with the interface designer or programmatically

enter image description here

yourLabel.font = UIFont.init(name: YourFont, size: size) 
+11
source
  • First of all, you need to drag the font into the project.
  • After that, you need to select the font and select the target tick for your application, as shown in the figure.

Xcode window with target membership selected for custom font

  1. After that, you will go to your Info.plist and add the font name in "Fonts provided by the application"

  2. Now you can finally use the als font, which you would use every other font. If it does not work, since you need to find out the name of Xcode, you will get a 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 is 100% free to use. Download here.

+8
source

I found this little tutorial very useful: https://grokswift.com/custom-fonts/

In addition, if you arbitrarily declare a font, be sure to check the font book to see what the exact file name is. If it does not succeed, Xcode will not know what to do.

The best

0
source

I would like to add this code if you know your family font name (which you can see in the Picker font in IterfaceBuilder) use this to apply the font programmatically

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

All Articles