开发者

Unable to see indian language characters even in android 2.3

开发者 https://www.devze.com 2023-02-06 21:26 出处:网络
I set String myText=\"\\u2327\\u2381\\u2352\\\"; and try to display itin a Textview but I just see 3 rectangular bo开发者_如何学编程xes in the android emulator.

I set String myText="\u2327\u2381\u2352\"; and try to display it in a Textview but I just see 3 rectangular bo开发者_如何学编程xes in the android emulator. Even though android 2.3 release note says that hindi is supported I still do not see hindi character appearing in the emulator.


Even if you have a Devanagari font installed you don't get proper rendering for Hindi text on Android phones.

The same apples to all complex Indic scripts (Bangla, Devanagari, Kannada, Tamil, Telegu, Tibetan, Punjabi, Sinhala, etc)

The problem is that, although Android "supports Unicode" there is no complex script rendering support - even in the Andoid 4.0 (ICS) emulator. Due to this letters don't join up to form conjuncts properly and so the text is pretty well unreadable.

Until Google fixes this Indian languages won't display properly.

This would actually not be very difficult for them to fix. In Linux (which Android is based on) complex text rendering for Indic scripts is supported by library known as Pango or Harfbuzz which is open source - but for some reason (lack of real interest in the Indian and South Asian market?) Google chose not to implement this in Android.

Indic scripts work fine on phones which use other Linux based operating systems such as Nokia's N900. Even some Symbian phones can display Indic text through the support in Qt.
Apple iPhone's now also display Indian languages properly.

If Google and their OEMs care about selling Android phones in India they really need to fix this defect urgently.


Indian Languages aren't currently supported in many devices, and including the emulator too.

Only Samsung devices being sold in India are supporting Hindi.

You're not alone with this problem mate! :-)


Android phones do not come with default hindi fault .

You have to make sure that you are using a custom Hindi Font.

Create a folder called fonts in your assests folder.

Put your custom_font_hindi.ttf in the assets/fonts.

 Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/custom_font_hindi.ttf");
        TextView tv = (TextView) findViewById(R.id.CustomFontText);
        tv.setTypeface(tf);

Then you will see the desired hindi font in your TextView


You can use DroidHindi.ttf font (for example. Search in google.com). Add it to assets folder in your project and load that font in your Views.

Typeface t = Typeface.createFromAsset(getContext().getAssets(), "DroidHindi.ttf");
textView.setTypeface(t);


I have Samsung Galaxy S. I have installed DDJV6 using Kies over JP6. But I am feeling absolutely cheated by Samsung as this so called 'Indian Release' does not support any Hindi or Indic fonts. I am talking about reading Hindi text. As far as text input is concerned, Hindi is not even shown as a data input language. Shame on Samsung that it cannot use the inherent features of Gingerbread! I am saying so because even Froyo Official release of Galaxy S in India could render Hindi fonts correctly. There were a lot of tall claims that Gingerbread would support 52 languages (both for reading and writing) and here is this Samsung that it can't even render Indic reading capabilities in Galaxy S based on Android 2.3.3.


Looks like a font problem, try to set your TextView to use a font with suitable glyphs.


I have found the solution for How to use hindi font use in Android. It is very simple solution. But hard to right Hindi font.

use

DroidHindi.ttf

it is the font which support for Hindi Language.

Download it and place in Assets folder. Do the following code to set the font:

TextView tv = (TextView) findViewById(R.id.textView);       

Typeface fontHindi = Typeface.createFromAsset(getAssets(),    "fonts/DroidHindi.ttf");      

tv.setTypeface(fontHindi);

Now you can find your solution easily.

Moreover you can put the Hindi text in .txt file and read from that also. Like this.

Place your all the hindi .txt files in Assets folder and call the function to retrieve Hindi text like:

public void readData(int tag) {


        // file to inputstream
        InputStream input = null;
        try { 

             int tagV = tag +1;

             input = ctx.getAssets().open("sample "+tagV+".txt");

             int size = input.available();
             byte[] buffer = new byte[size];
             input.read(buffer);
             input.close();

            // byte buffer into a string

             detailtext = new String(buffer);
         } catch (IOException e) {

             e.printStackTrace();
         }

     }

I am using 15 files here so i undergo the loop.

0

精彩评论

暂无评论...
验证码 换一张
取 消