我正在尝试使用以下代码支持 android 2.x 的梵文字体(即使 android 2.x 无法渲染梵文字体)。除了“raswa”和“dirga”存在一些问题之外,代码工作正常。是否有可能在 android 2.x 中获得正确的梵文表示形式?
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/mangal.ttf");
TextView txtviewword=(TextView) findViewById(R.id.textViewWord);
txtviewword.setTypeface(typeface);
这是不正确的表示(来自 android 2.3):
这应该是这样的(从 android 4.4 开始):
在分析了我对这个问题的情况后,我发现将“raswa”的位置与字母表(“akshar”)本身交换可以解决姜饼的问题。所以,我交换了“raswa”和字母的位置。因此,这提供了问题的解决方法。
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
char[] array = content[1].toCharArray(); /*content[1] is a string containing the original version */
for(int i=0; i<array.length; i++){
char c = array[i];
int code = (int) c;
if (code == 2367){ //2367 is int value for 'raswa'
char temp = array[i-1];
array[i-1]=c;
array[i]=temp;
}
}
String str = String.copyValueOf(array); /*This string contains the swapped version(symantically its wrong, though. It's works as my solution.)*/
Log.d("DetailActivity", "from gingerbread");
Log.d("DetailActivity", str);
if(!content[1].equals(null))txtviewdevanagari.setText(str);
}else{
Log.d("DetailActivity", "from ICS+");
if(!content[1].equals(null))txtviewdevanagari.setText(content[1]);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)