title: Draw chinese font glyphs with Quartz 2D?
body: <p>I have to show Chinese characters with the function:</p>
  
  <pre><code>CG_EXTERN void CGContextShowGlyphsAtPoint(CGContextRef context, CGFloat x,
  CGFloat y, const CGGlyph glyphs[], size_t count)
  </code></pre>
  
  <p>But it doesn't show accurately. The code I use is as follows:</p>
  
  <pre><code>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 &lt; [label.text length]; ++currentChar)
  {
      glyphs[currentChar] = Chars[currentChar];
  }
  CGContextShowGlyphsAtPoint(theContext, 0, (size_t)label.font.ascender, glyphs, [label.text length]);
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>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".</p>
  
  <p>How to solve this problem? Thanks!</p>