6
votes

For some reason many of the fonts will not display in Interface Builder when I am designing my iPad app. Unfortunately my iPad is yet to be delivered so I cannot tell if this is going to be a problem in the long run, but it certainly maintains through to the simulator.

The fonts in question are listed on various websites as being compatible with the iPad but SDK 4.0.1 still seems to be confused.

For example Hoefler Text font assigned to a label drawn directly on fresh iPad view displays using the default font. If I click to edit the text it displays in the correct font. I've tried it on a couple of macs now

This is a problem as I need to send through the app mock ups to my client to sign of the pixel perfect layouts for their backend team :(

Any ideas?!

3
why cant I tag this iphone-sdk? every time I do it just ignores it?!?!Anthony Main

3 Answers

9
votes

For others who might be interested: there is a bug/known issue with IB on XCode 3.x with non-standard fonts and Interface Builder. Custom fonts generally need to be set programatically (via [UIFont fontWithName...).

For mockups you should use a tool like PhotoShop, etc rather than Interface Builder.

3
votes

using custom fonts in Interface Builder a reusable library is available.

It uses a simple trick for doing this. Set the font(say calibri) to all of your UI Elements that you will never use in your project and FontReplacer will do mapping between custom font and calibri. So there is no need to make IBOutlets or any other graphics.

Here is link to github from where you can download FontReplacer to use in your project. https://github.com/0xced/FontReplacer

2
votes

I solved this by writing a custom category on UILabel. That category has a 'myFontName' property that I set on the label using objc_setAssociatedObject, and get from the object using objc_getAssociatedObject.

I then wrote another method in the category called 'updateWithMyFont' that sets the font on the label via the label's attributed text property ( grab the attributedText and copy the attributes, set the font, create a new attributed string, set the attributedText property).