I have to show Chinese characters with the function:
CG_EXTERN void CGContextShowGlyphsAtPoint(CGContextRef context, CGFloat x,
CGFloat y, const CGGlyph glyphs[], size_t count)
But it doesn't show accurately. The code I use is as follows:
CGFontRef cgfont = CGFontCreateWithFontName((CFStringRef)label.font.fontName);
CGContextSetFont(theContext, cgfont);
CGContextSetFontSize(theContext, label.font.pointSize);
CGContextSetTextDrawingMode (theContext, kCGTextClip);
CGGlyph *glyphs = malloc(sizeof(CGGlyph) * [label.text length]);
char *Chars = malloc(sizeof(char) * ([label.text length] + 1));
[label.text getCString:Chars maxLength:([label.text length] + 1) encoding:NSISOLatin2StringEncoding];
for(int currentChar = 0; currentChar < [label.text length]; ++currentChar)
{
glyphs[currentChar] = Chars[currentChar];
}
CGContextShowGlyphsAtPoint(theContext, 0, (size_t)label.font.ascender, glyphs, [label.text length]);
Edit
The device is iPhone. For example, I want show the Chinese characters like "中文", but use CGContextShowGlyphsAtPoint to draw the string will show like this "@#Radcx67".
How to solve this problem? Thanks!