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
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;
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.
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