Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retina display core graphics font quality

Trying to understand why am I getting low quality drawing with CGContextShowTextAtPoint? See attached image: img

The letter "W" is drawn using CGContextShowTextAtPoint on a CALayer and looks very pixelized. The button next to it is a standard button and looks high res as expected. I would like to get the text drawing to be hi-res.

enter image description here

like image 967
vance Avatar asked Mar 24 '11 04:03

vance


1 Answers

By default, your CALayer is not rendering its Quartz content at the higher resolution of the Retina display screen. You can enable this using code like the following:

if ([layer respondsToSelector:@selector(setContentsScale:)])
{
    layer.contentsScale = [[UIScreen mainScreen] scale];
}

This will affect not just text rendering, but all of your Quartz drawing within CALayers, so you'll need to do this for all of your layers with custom Quartz content.

like image 195
Brad Larson Avatar answered Sep 23 '22 22:09

Brad Larson