开发者

CoreGraphic - display umlaut mark on an i

I'm to trying to display an umlaut mark on an i in my CoreGraphics function: ï. I tried to use it's unicode representation (ï), but I don't manage to get it right.

here is my code:

void drawColorString(CGContextRef ctx, NSString *text, UIColor *color, CGPoint pos){
    CGContextSaveGState(ctx);
    [color setFill];
    CGContextSelectFont(ctx, "Georgia-BoldItalic", 14, kCGEncodingMacRoman);
    CGContextSetTextDrawingMode(ctx, kCGTextFill);
    CGAffineTransform xform = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
    CGContextSetTextMatrix(ctx, xform);
    CGContextShowTextAtPoint(ctx, pos.x, pos.y, [text UTF8String], text.length);
    CGCont开发者_如何学CextRestoreGState(ctx);
}

it works very well for regular strings, but I get a square for each special char...

Can anyone help me?

Thanks. R.


Drawing text in Quartz sucks. One reason is that it doesn't support Unicode: Your choices are plain old ASCII and MacRoman. You might be able to do it by looking up the glyphs for the characters, but that's not fun at all and I bet there are some easy ways to get it wrong.

You can draw a ï in MacRoman easily enough, but a far better solution is to switch to Core Text.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜