iOS Custom Font

Use custom font for iOS

iOS covers a lot of font in OS. But there are some cases we want to use original, not covered font.

Example Use Keifont

K-Fontis Japanese Animation “けいおん” like font.
This is Apache License 2.0. This has
Download files from this web site and unzip

Font file type


iOS supports following font file.

  • PostScript Type1 based OpenType(.otf)
  • True type based OpenType(.ttf)

K-font has ttf file in download folder, copy this file to your iOS Project like other resources.

Certainly, font file seems to be a bit heavy.

Font family name

To use font, we need to call fontWithName method.
This API requires font name, but how to know font name?
Use mdls

mdls keifont.ttf

From command results, we can get fontWithName name.

com_apple_ats_name_postscript  = (
    Keifont
)

You can find this from results. The results are json and include font information of ttf.
O.K. You can get “Keifont”, this is font name.

How to use?

Very simple

UIFont *font = [UIFont fontWithName:@"Keifont" size:15];

Setting in Info.plist

Add new row
Fonts provided by application item0 keifont.ttf

Ref

iOSアプリに独自フォントを組み込んで表示する