On Aug 11, 2011, at 10:57 AM, Stevo Brock wrote: > We have an existing PDF Report creation module in one of our apps that is > working great... for English text. This is what we are doing: > > NSFont* font = [NSFont fontWithName:@"Helvetica" size:12.0]; > CGContextSelectFont(state->mContextRef, [[font fontName] UTF8String], > [font pointSize], kCGEncodingMacRoman); > > NSData* data = [string dataUsingEncoding:NSMacOSRomanStringEncoding]; > CGContextShowTextAtPoint(state->mContextRef, drawPt.x, drawPt.y, > (char*) data.bytes, data.length); > > We have a user who is entering Chinese text, which is obviously not making it > to the PDF through this mechanism.
Chinese text (and most non-Western text) can't be represented in MacRoman. As a general rule, this method of drawing text is highly discouraged, at minimum because of its limited text support. > What is the recommended approach for taking an NSString* of text and drawing > it to a CGContextRef where the text may contain characters of any language? For simple needs, the NSString additions (on either Mac OS X or iOS) would be recommended. There are platform specific methods for making a CGContextRef current. For more complex needs, NSLayoutManager (Mac OS X only) or Core Text (both) can be used as well. -- David Duncan _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com