开发者

Disabling Anti-Aliasing for fonts

开发者 https://www.devze.com 2022-12-22 09:32 出处:网络
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 i

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


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. ^^


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消