How to Display different Custom arabic fonts in iPhone application?

前端 未结 2 360
一向
一向 2021-01-06 08:23

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

2条回答
  •  伪装坚强ぢ
    2021-01-06 08:51

    @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 enter image description here

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

    enter image description here

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

提交回复
热议问题