Dipaly farsi text in android webview (for phones not supporting farsi)

家住魔仙堡 提交于 2019-12-01 20:00:36

问题


In farsi letters are attach together to form writing scripts. However when I save HTML pages using "UTF-8" or "Windows-1256" encdoings, and try to display them using webview in android, letters are diplayed seperately and in left-to-right direction (instead of RTL). I should notice that this case is not happening in phones supporting farsi.

Correct form should be like this (snapshot from phone supporting farsi):


Bad-formed text happens in phones not supporing farsi (Persian):

It should be noticed i've used persian font in both cases. I also see some solutions for normal Strings in java which changes character on by one in this question

My question: Can i fix this cases (or it should be fix by phone vendors)? if possible what is solution?


回答1:


I hit this bug a lot when I was doing keyboards. The problem is that the build in canvas.drawText function in Android didn't support RTL languages. There was a patch for it, but it wasn't part of the default build of Android. So only models going out to those parts of the world that used it tended to have it. Unfortunately I know of no way to test whether it has the patch. And if it doesn't, there's no way to fix it. You could try reversing the text, but then you'd break devices which did have the patch.

Long story short- there is no way to fix it. However, I'd be shocked if Google hasn't picked up the patch in mainline by now (it existed back in the 2.2 days), so its a shrinking number of phones effected.




回答2:


You can try making html with reverse font sequence! just write a windows app to get font and deliver reverse one, and use it in your android device



来源:https://stackoverflow.com/questions/15855875/dipaly-farsi-text-in-android-webview-for-phones-not-supporting-farsi

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