views:

429

answers:

2

Hi,

I'm using CGContextShowGlyphsAtPoint in my application to render characters that follow a path. I'd had no problems with this at all until I started on i18n of the application and found that Japanese characters appear fine everywhere apart from when I try to render them using this function.

Is there a way to have these characters appear properly, as opposed to being rendered as empty boxes? Stupidly, I didn't see this coming (newbie iPhone developer) and I really need to support these characters :(

I've been searching stackoverflow and google all day but seem to be getting nowhere with this.

Thanks for any help you can offer,

Bryn

A: 

I did not know this, but I did some digging and I'll tell you what I found:

  1. The Quartz2D Programming Guide refers to the "ATSUI Programming Guide" but has no active link.
  2. Google turned up a cached copy of the legacy ATSUI Carbon API here
  3. Apple states here that you should not use ATSUI, but instead use CoreText
  4. There is an open radar to port CoreText to iPhone since 31-Jul-2009 12:54 PM

Sorry mate :(

slf
+1  A: 

This is a very similar question to your own. Basically, it is very difficult to get the appropriate glyphs for doing pure Quartz drawing of text, so I recommend using the NSString UIKit category method -drawAtPoint:withFont:. This will get you all the support that NSString has for languages, while letting you draw directly to a Core Graphics context. It's what we use in the Core Plot framework for text rendering within a CALayer.

However, drawing this way is much slower than pure Quartz text rendering, so if you're doing a lot of text drawing it could slow things down in your application. Also, the UIKit extensions to NSString take into account the flipped graphics context of UIViews and their CALayers, which has caused others problems.

Brad Larson