旁遮普语的文本不能在Android中正确显示 [英] Punjabi Text is not appearing properly in Android

查看:155
本文介绍了旁遮普语的文本不能在Android中正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的code,其中我使用的字体正确地更改旁遮普语的字体,但仍表现出比三星其他手机上的Galaxy S2和标点符号不正确的文本。不知道如何才能解决这个问题。

 保护无效的onCreate(捆绑savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activity_main);
    字体TF = Typeface.createFromAsset(getAssets()
            字体/ ANMOL_L.TTF);
    TextView的TXT =(的TextView)findViewById(R.id.text);
    txt.setTextSize(40);
    txt.setTypeface(TF);
    txt.setText(ੴਸਤਿਨਾਮੁਕਰਤਾਪੁਰਖੁਨਿਰਭਉਨਿਰਵੈਰੁਅਕਾਲਮੂਰਤਿਅਜੂਨੀਸੈਭੰਗੁਰਪ੍ਰਸਾਦਿ。);
    }
}


解决方案

尝试txt.setText(测试);而且你会发现,你会看到旁遮普语文字。这是因为您选择的字体不是单向code兼容的字体。它覆盖ASCII codeS。请选择其他字体文件。

我已经测试AnmolUni.ttf和AmbarSlim.ttf文件从 HTTP://www.gurbanifiles .ORG / UNI code / 以及他们的工作。

Below is my code where I am using typeface correctly to change the font for the punjabi but it is still showing incorrect text on Galaxy S2 and punctuations on phones other than Samsung. Not sure how can I fix this

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Typeface tf = Typeface.createFromAsset(getAssets(), 
            "fonts/ANMOL_L.TTF");
    TextView txt = (TextView) findViewById(R.id.text);
    txt.setTextSize(40);
    txt.setTypeface(tf);
    txt.setText("ੴ ਸਤਿ ਨਾਮੁ ਕਰਤਾ ਪੁਰਖੁ ਨਿਰਭਉ ਨਿਰਵੈਰੁ ਅਕਾਲ ਮੂਰਤਿ ਅਜੂਨੀ ਸੈਭੰ ਗੁਰ ਪ੍ਰਸਾਦਿ ॥");
    }
}

解决方案

Try txt.setText("Testing"); And you will notice you will see Punjabi text. This is because the font you have chosen is not a Unicode compatible font. It overrides ASCII codes. Choose another font file.

I have tested AnmolUni.ttf and AmbarSlim.ttf files from http://www.gurbanifiles.org/unicode/ and they work.

这篇关于旁遮普语的文本不能在Android中正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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