如何在 iPhone 应用程序中显示不同的自定义阿拉伯字体? [英] How to Display different Custom arabic fonts in iPhone application?

查看:21
本文介绍了如何在 iPhone 应用程序中显示不同的自定义阿拉伯字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我需要使用不同的自定义字体显示阿拉伯文本.我遵循将 ttf 文件添加到 info.plist 的场景.

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

根据上述情况,我仅成功获得了 ENGLISH 文本的不同字体样式的显示文本.我正在为 arabic 字体样式做同样的事情,但在这里我没有得到.为什么会这样?

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?

请任何人可以帮助我

提前致谢.

推荐答案

@Kareem ,我从 Stackoverflow 本身得到了提示来加载字体,但在第一次运行时无法让它工作.可能以下步骤可以帮助您.

@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. 将字体文件添加到您的项目中.
  2. 在 info.plist 文件中输入他们的条目

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

比如

你现在可以实现一些方法来加载你的字体应用委托喜欢

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

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

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

    UIFont* customFont = [UIFont fontWithName:@"FX_Masa" size:size];

    if(customFont == nil)
        customFont = [UIFont systemFontOfSize:size];

    return customFont;
}

如果你注意到我在这里传递的名字是FX_MASA"而不是 FX_MasaRegular ,这就是我错的地方.我们在获取字体时需要使用的名称是INSTALL NAME(双击字体在系统上安装该字体,Font Book中出现的名称是安装名称).

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.

这篇关于如何在 iPhone 应用程序中显示不同的自定义阿拉伯字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆