You can make a faster drawing using the following code:
CGContextSetStrokeColorWithColor(context, strokeColor); CGContextSetFillColorWithColor(context, strokeColor); CGContextSelectFont(context, "Helvetica", fontSize, kCGEncodingMacRoman); CGContextSetTextDrawingMode(context, kCGTextFill); CGContextSetTextPosition(context, 0.0f, round(fontSize / 4.0f)); CGContextShowText(context, [text cStringUsingEncoding:NSMacOSRomanStringEncoding], strlen([text cStringUsingEncoding:NSMacOSRomanStringEncoding]));
However, the Mac Roman encoding for the Helvetica font on iPhone lacks characters for many non-English characters, so I think you're stuck with NSString's drawing methods if you don't want to switch to Core Text on iPhone OS 3.2.
To check and see if your string can be represented using the Mac Roman character set, use something like the following:
if ([text canBeConvertedToEncoding:NSMacOSRomanStringEncoding])
source share