First time poster, but I'm hoping someone may have some advice.

I'm using the "unofficial" iPhone SDK to develop a text reader named, well, textReader - see http://code.google.com/p/iphonetextreader/.

I've had a lot of requests to support different encodings - especially Chinese. The problem is, I can't seem to get CGContextShowGlyphs() to actually draw the glyphs.

For example, the code below *ought* to draw a Chinese character, but it doesn't ... I looked at the cmap table in the arialuni.ttf (Arial Unicode MS) font and the glyph mapping is correct and contained in the font, but CGContextShowGlyphs refuses to draw it ... anybody have any advice on what I'm doing wrong?

Thanks,
-Jim

-------------------------------------------------------

// missing prototypes
bool CGFontGetGlyphsForUnichars(CGFontRef, unichar[], CGGlyph[], size_t);
extern CGFontRef CGFontCreateWithFontName (CFStringRef name);

...
- (void)drawRect: (struct CGRect)rect
{
CGContextRef context = UICurrentContext();
CGFontRef fontRef = CGFontCreateWithFontName((CFStringRef)@"arialuni") ;
CGContextSetFont(context, fontRef);
CGContextSetFontSize(context, 20.);
CGAffineTransform myTextTransform;
myTextTransform = CGAffineTransformMake(1, 0, 0, -1, 0, viewSize.height/30);
CGContextSetTextMatrix(context, myTextTransform);

CGContextSetRGBFillColor(context, 1, 1, 1, 1);
CGContextSetRGBStrokeColor(context, 1, 1, 1, 1);

// try the proper way to map the char to a glyph
uint16_t c = 0x672C; // Chinese character
CGFontGetGlyphsForUnichars(fontRef, &c, &glyph, 1);

CGContextShowGlyphs(context, &glyph, 1);

// Force the proper glyph by looking at the font cmap table
CGGlyph glyph = 0x39bb-1; // Chinese glyph in arialuni corresponding to
// character 0x672C

CGContextShowGlyphs(context, &glyph, 1);

} // drawrect