Problem using custom Arabic font on iPhone

2019-07-30 23:05发布

I'm developing an iPhone application with MonoTouch that uses a custom Arabic font (Scheherazade from http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=ArabicFonts). I don't have problems getting the font loaded in my application. I also see that it is used when I use Latin text but when I want to display Arabic text it uses a default system font for displaying the text.

Does anyone have any experience with custom Arabic fonts and MonoTouch/iPhone development or has an idea why this is happening?

Thank you in advance.

With kindest regards,

Taner Gedikoglu

3条回答
Ridiculous、
2楼-- · 2019-07-30 23:20

These classes will do the job :

https://github.com/Accorpa/Arabic-Converter-From-and-To-Arabic-Presentation-Forms-B

Download them, and I'm pretty sure that answers your question because I had the exact same problem before!

An example of the code :

ArabicConverter *converter = [[ArabicConverter alloc] init];
NSString* convertedString = [converter convertArabic:@"منذ دقيقة"];
infoText.font = [UIFont fontWithName:@"YOUARABICFONT" size:16];
infoText.text = convertedString;
查看更多
女痞
3楼-- · 2019-07-30 23:23

If you're targeting iOS 6, you can use NSAttributedString to achieve this a lot more simply:

NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:info.text attributes:@{ NSFontAttributeName : [UIFont fontWithName:@"Scheherazade" size:32], NSLigatureAttributeName: @2}];

cell.textLabel.attributedText = attributedString;

Refer to my answer here for some discussions on other matters commonly relevant to arabic fonts such as line-spacing and ligatures.

查看更多
时光不老,我们不散
4楼-- · 2019-07-30 23:31

The API you use to show the text could be the issue you're facing. Look at this question (and answer): no german umlaute in CGBitmapContext

查看更多
登录 后发表回答