开发者

Localize text into chinese using custom fonts

I know how to use custom fonts to display CCLabels. I also figured out how t开发者_开发百科o localize the Labels. But I am wondering if there is anyway to display the localized text using custom fonts.

For example when I use Arial I have no problems, the chinese fonts appear correctly. But when I use a font not included in XCode such as ARLRDBD.TTF then the chinese characters do not get displayed.

How can I display the chinese characters in ARLRDBD.TTF too? Or am I stuck with just using the default fonts included in XCode if I plan to use LocalizedString?

Thanks Abhinav


You should be able to use any font that has Chinese characters in it.

Not all fonts include characters for all languages. Many Western fonts only have the Roman alphabet (A-Z).

You could either use a font that has all the characters you will need (like Arial, or another Unicode font - see: http://en.wikipedia.org/wiki/Unicode_typeface), or have separate fonts for each language.

I'd suggest a different font for each language. You could keep it organized with a simple struct.

typedef struct {
  NSString *regionname;
  NSString *fontname;
} RegionFont;

//later in the code....
RegionFont some_region;
some_region.regionname = @"China";
some_region.fontname = @"Arial";

You can test if a font supports a given language by opening Font Book (standard Mac app) and searching under "All Fonts" for the language you want.

I don't have many custom fonts installed and several with Chinese support come up.

Hope this helps.


You can use custom fonts in your app but you need to make the system aware that they exist using the UIAppFonts key in your Info.plist file. See here for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜