FontReplacer 1.0

FontReplacer 1.0

TestsTested
LangLanguage Obj-CObjective C
License Custom
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total579
Week0
Month0

Installs

Apps15
Test Targets2
powered by Segment

GitHub

Stars241
Watchers14
Forks60
Issues0
Contributors1
Pull Requests0

Code

Files2
LOCLines of Code 72


  • By
  • Cédric Luthi

About

Since iOS 3.2, you can use custom fonts in your apps but unfortunately, you can't use these custom fonts in Interface Builder. FontReplacer is a solution to this problem.

If your project contains nibs with a lot of labels, it becomes tedious to setup an outlet for every label and change the font in the code for each outlet. Instead choose a font that you won't be using anywhere in your app, e.g. Arial and use it in Interface Builder. Then create a mapping from Arial to your custom font, e.g. Caviar Dreams and let FontReplacer handle the replacement.

Here is what you see in Interface Builder vs what you see at runtime:
Font in Interface Builder Font at Runtime

Usage

  1. Copy UIFont+Replacement.h and UIFont+Replacement.m into your Xcode project
  2. Create a replacement dictionary in your Info.plist with the ReplacementFonts key, for example

    ReplacementFonts = {
        "ArialMT" = "CaviarDreams";
        "Arial-ItalicMT" = "CaviarDreams-Italic";
        "Arial-BoldMT" = "CaviarDreams-Bold";
        "Arial-BoldItalicMT" = "CaviarDreams-BoldItalic";
    };
    
  3. Use Arial in your nibs everywhere you want Caviar Dreams

If you want more control, you can use the +[UIFont setReplacementDictionary:] method instead of defining the ReplacementFonts Info.plist key. Make sure to call this early enough, before any font is deserialized from a nib.