0
votes

I think I might already know the answer, but here is the situation:

I have a spec sheet that requires the font size to be: 11pt.

When I do: UIFont *font = [UIFont fontWithName:@"Gotham" size:11.0]; Then font is tiny on my retina iPad 4.

When I double the point count with: UIFont *font = [UIFont fontWithName:@"Gotham" size:22.0];

The size looks right. Am I right to assume that I should double the font point count for @2x devices? Just as one would for a png.

Edit:

Thanks for clearing that up. I get that: UIFont *font = [UIFont fontWithName:@"Gotham" size:11.0]; Will produce the same size on Retina/Non-retina.

Now for possibly more dumb follow up:

When I open up the photoshop file (scaled at @2x) the font reads 11pt. When I export the file (converted to png and labeled @2x) and I drop the png into the project, why does the image's text still appear significantly bigger than the text I created programmatically at 11pt? (Both the image and programatic text are being viewed within the iPad)

I'm probably having a brain fart, but any help finding the solution would be appreciated.

2
Is there a typo in your question? Both fonts are size 11.rmaddy
Yes, there was. Thank you.user3666483

2 Answers

3
votes

No, you don't need to scale font sizes. Font sizes are in points, not pixels. The reason why 11.0 seems tiny to you is because it really is ;-)

But the size should be the same regardless wether it's a retina device or not.

0
votes

If you are doing this right, you should be able to ignore pixels and think entirely in terms of points, the native measurement unit:

  • If you have a built-in interface widget, such as a UILabel, then [UIFont fontWithName:@"Gotham" size:11.0] will look the same size on Retina and non-Retina devices (but sharper on Retina).

  • If you are constructing an image in real time (in code), and you are using this font to draw into the image, then if this is to be a 2x image for double-resolution screen, then you should be using a double-resolution graphics context (e.g. you set this up with UIGraphicsBeginImageContext(size,NO,0)) and once again [UIFont fontWithName:@"Gotham" size:11.0] will look the same size on Retina and non-Retina devices (but sharper on Retina).

On the other hand, let's say you are preparing an image in Photoshop, to be used later in your iOS app (e.g. for an icon), and this image has some font drawing within it. Then of course for a 2x version of the image you must double the font size, just as you are doubling the size of everything in the drawing.