android webview 中的 Dipaly 波斯语文本(适用于不支持波斯语的手机) [英] Dipaly farsi text in android webview (for phones not supporting farsi)

查看:29
本文介绍了android webview 中的 Dipaly 波斯语文本(适用于不支持波斯语的手机)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在波斯语中,字母连接在一起形成书写脚本.但是,当我使用UTF-8"或Windows-1256"编码保存 HTML 页面并尝试在 android 中使用 webview 显示它们时,字母会以从左到右的方向(而不是 RTL)单独显示.我应该注意到这种情况并没有发生在支持波斯语的手机中.

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

应该注意我在这两种情况下都使用了波斯字体.我还看到了一些针对 java 中普通字符串的解决方案,这些解决方案在此将字符更改为一个问题

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?

推荐答案

我在做键盘的时候经常遇到这个错误.问题是 Android 中内置的 canvas.drawText 函数不支持 RTL 语言.它有一个补丁,但它不是 Android 默认构建的一部分.因此,只有面向世界上那些使用它的地区的模特才会拥有它.不幸的是,我没有办法测试它是否有补丁.如果没有,就没有办法修复它.你可以尝试反转文本,但你会破坏确实有补丁的设备.

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.

长话短说 - 没有办法解决它.但是,如果谷歌现在还没有在主线中找到补丁(它早在 2.2 天就存在),我会感到震惊,因此它影响了手机数量的减少.

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.

这篇关于android webview 中的 Dipaly 波斯语文本(适用于不支持波斯语的手机)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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