How to Display different Custom arabic fonts in iPhone application?

折月煮酒 提交于 2019-11-30 17:29:24

问题


In my application i need to display arabic text with different custom fonts. I follow the scenario adding ttf files to info.plist.

As per above scenario i am successfully getting display text in different font style for ENGLISH text only. I am doing same thing for arabic font styles but here i am not getting. Why is going like that?

Please any one can help me

Thanks in Advance.


回答1:


@Kareem , I took hint from Stackoverflow itself to load the fonts but could not get it working in first go. May be following steps can help you .

  1. Add the font files to your project.
  2. Make their entries in info.plist file

    such as

  3. you can now implement some method that loads your font somewhere in application delegate like

    -(UIFont*) CustomFontWithSize:(float)size{

        UIFont* customFont = [UIFont fontWithName:@"FX_Masa" size:size];
    
        if(customFont == nil)
            customFont = [UIFont systemFontOfSize:size];
    
        return customFont;
    }
    

If you notice then the name I have passes here is "FX_MASA" and not FX_MasaRegular , this was the point where I was wrong. The name that we need to use while fetching the font is the INSTALL NAME (Double click on the font to install the font on system and the name that appears in Font Book is the install name).

Hope this helps your problem as well. In case you come across any good method, please update here.




回答2:


It might not be possible.

Are you sure the font is loaded ? this question shows some code to check it.

Also this user seemed to have the same issue - the question is unanswered, but you maybe it's worth contacting him to see if he figured it out




回答3:


There is a nice UILabel extension in GitHub called "Font Label": https://github.com/zynga/FontLabel This allows to load any TTF file and then draw ZLabel objects (ZLabel is an extension of UILabel) with this custom font. It is based on CoreGraphics and I tested with many custom fonts and proved to work correctly. I don't know of course the effect with arabic fonts, but it's worth a try and a feedback from you (to us and also the github project admins) is welcome.



来源:https://stackoverflow.com/questions/8223538/how-to-display-different-custom-arabic-fonts-in-iphone-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!