関数で漢字を表示する必要があります。
CG_EXTERN void CGContextShowGlyphsAtPoint(CGContextRef context, CGFloat x,
CGFloat y, const CGGlyph glyphs[], size_t count)
しかし、正確には表示されません。私が使用するコードは次のとおりです。
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]);
編集
端末はiPhoneです。たとえば、漢字を「中文」のように表示したいのですが、CGContextShowGlyphsAtPoint を使用して文字列を描画すると、「@#Radcx67」のように表示されます。
この問題を解決するには?ありがとう!