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:
-
Copy UIFont+Replacement.h and UIFont+Replacement.m into your Xcode project
-
Create a replacement dictionary in your
Info.plist
with theReplacementFonts
key, for exampleReplacementFonts = { "ArialMT" = "CaviarDreams"; "Arial-ItalicMT" = "CaviarDreams-Italic"; "Arial-BoldMT" = "CaviarDreams-Bold"; "Arial-BoldItalicMT" = "CaviarDreams-BoldItalic"; };
-
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.