Custom Arabic font in iOS

前提是你 提交于 2019-11-27 07:20:51

Short answer

This seems to be a bug in iOS.

Long answer

As you may know, the arabic text needs to be shaped before it can be rendered, that means converting the basic letters (Unicode:0600-06FF) to their proper corresponding contextual letters (Unicode:FE70-FEFF).

iOS does this preprocessing automatically for arabic text, but for some reason, it forgets about the custom font and just uses system default font when it renders the connected letters.

So, it's a bug in iOS and you should wait for it to be solved.

Workaround

Though, if you can't wait, you can use this workaround: Do the preprocessing of the text manually before rendering it. This will allow skipping iOS preprocessing phase which causes this issue and thus rendering the text using your custom font.

If you want to test this solution, just copy this following line and try it in your project:

arabicLabel.text = @"ﺍﻟﺴﻼﻡ ﻋﻠﻴﻜﻢ";

THIS ANSWER IS FOR BELOW IOS 7.

I have also gone through this situation u can create your own hash map method for the replacement of 0600-06ff char with ur custom font but for that u need to check if your glyph in the TTF is mapped against 0600-06FF than u need to modify ur glyph mapped unicode except from 0600-06ff

for example if i made a TTF and mapped 'و' with unicode 0627 and when i try to see the effect of typed unicode 0627 char i.e(when i type 'ا' it must show 'و') it will not apply my custom image against it because ios6 will not allow u to change the glyph on the particular range . but if i would have mapped this custom char with Fxxx series or other than of 0600-06ff it will easily allow me to made custom change

Arabic(0600—06FF, 255 characters) u cannot play on this range or change the image of these glyph image with your custom image so mapped your glyph against the below arabic unicode Arabic Supplement (0750—077F, 48 characters) Arabic Extended-A (08A0—08FF, 39 characters) Arabic Presentation Forms-A (FB50—FDFF, 608 characters) Arabic Presentation Forms-B (FE70—FEFF, 140 characters)

here is the link for the similar type of thing done using custom arabic class and i also took help from it arabic custom font class

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