Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
479 views
in Technique[技术] by (71.8m points)

unicode - Iphone CGContextShowTextAtPoint for Japanese characters

I am working on an app where I am using CGContextShowTextAtPoint to display text to the screen. I want to also display Japanese characters, but CGContextShowTextAtPoint takes as its input a C string. So either A) How do I change Japanese characters into a C string? If this is not possible, B) How can I manually print Japanese characters to the screen (within the drawRect method).

Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

CoreText can help you:

  1. CTFontGetGlyphsForCharacters (iOS 3.2 onwards) maps Unicode characters to glyphs
  2. CTFontDrawGlyphs (iOS 4.2 onwards) draws the glyphs into a CGContext.

NB. CGContextShowGlyphs should work, but I never found a way to convert my UniChars to glyphs. More on that here:

Ancient, pre iOS 3.2 answer

you need to use UIKit for this.

Check out [NSString drawAtPoint:...] to get started.

This SO question is useful, too.

I don't know what they were thinking with the CoreGraphic text stuff, it's useless.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...