views:

267

answers:

2

Hi, I'm writing a retro type game for the iPhone, and need to render a pixel style font to the screen. However, it looks nice and sharp when I run it in the simulator, but not when I run it on the device. Is there any way that I can disable Anti-Aliasing for fonts? I have already tried this:

CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetShouldSmoothFonts(c, FALSE);
CGContextSetShouldAntialias(c, FALSE);
CGContextSetAllowsAntialiasing(c, FALSE);

Also, I'm using the font rendering class from http://github.com/zynga/FontLabel/tree/master

A: 

Make sure that the views and / or layers in the hierarchy leading down to where your text is being drawn are aligned to integral pixel boundaries ( (10.0, 20.0), etc.). This can cause blurring of the drawn text.

Additionally, looking at the code for FontLabel, I don't think it takes into account the fact that Quartz drawing is aligned to half-pixel coordinates (you need to draw at (10.5, 20.5) to get sharp features, for example). I'm not quite sure where to correct this, but you could try shifting the point in -drawTextInRect: by a half pixel in X and Y and see if that clears up the font drawing.

Brad Larson
+2  A: 

Figured it out, when I was rotating my UIView to draw in landscape mode, I wasn't using enough digits for PI (3.14159 vs 3.14159265), and that fixed it. ^^

iAlexTsang