MoarFonts

Use custom fonts for your iOS projects directly in Interface Builder, the WYSIWYG way

by Cédric Luthi “​​0xced​​”

About

Since iOS 3.2, you can use custom fonts in your iOS apps by adding the ​​UIAppFonts​​ Info.plist key. Unfortunately, custom fonts are not available when editing your xib files in Interface Builder. MoarFonts makes your custom fonts available right within Interface Builder.

MoarFonts is compatible with both Xcode 4 and Xcode 5.

 

 

If you are using MoarFonts in a team, you must purchase one license per user, including your continuous integration server if applicable.

Usage

In your project, add a ​​Run Script Build Phase​​​ with ​​/bin/bash -e​​ as shell and the following script:

mdfind -onlyin "${SRCROOT}" "kMDItemContentTypeTree == public.font" -0 | sort -z | xargs -0 /usr/local/bin/moarfonts install

This will make all fonts in your project directory available in Xcode. You will need to relaunch Xcode the first time you build your project.

Limitations

  • There is currently no demo nor trial version available.
  • MoarFonts will not work if you copy the iOS 6 SDK from Xcode 4 to Xcode 5. Note that this is not supported by Apple and that you should keep a copy of Xcode 4 anyway if you still plan to build with the iOS 6 SDK.

Testimonials

Screenshot

IOS MoarFonts——字体定制:所见即所得_shell

Troubleshooting

  • Symptom: The custom fonts are not available in Interface Builder.
  • Solution #1: Make sure to quit and restart Xcode the the first time you build your project with the MoarFonts script phase.
  • Solution #2: If Spotlight is disabled the mdfind command will not find any font to install. In your script phase, replace mdfind -onlyin "${SRCROOT}" "kMDItemContentTypeTree == public.font" -0 with find "${SRCROOT}" -name "*.[ot]tf" -print0
  • Symptom: The following error occurs while running the MoarFonts script phase.

Failed to install Caviar Dreams: The file “Caviar Dreams.ttf” couldn’t be opened because there is no such file.

  • Solution #1: Install Xcode from the ​​dmg file​​ instead of from the Mac App Store.
  • Solution #2: In a terminal, type the following commands (adapt the SDKROOT environment variable if necessary) then build your project again. export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk /usr/local/bin/moarfonts reset

If you are still having issues with MoarFonts, please contact me by ​​e-mail​​ rather than twitter. Doing support in 140 characters is too hard.