Arabic text with custom fonts in iOS

前端 未结 5 1960
礼貌的吻别
礼貌的吻别 2020-12-16 06:33

I\'m working on an application that requires arabic text to be displayed, using custom arabic font. The problem is that i\'m not having any luck in displaying the arabic tex

5条回答
  •  时光取名叫无心
    2020-12-16 06:45

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

    NSMutableAttributedString *attributedString = [[NSMutableAttributedString 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.

提交回复
热议问题