Android: unable to show correct hindi words
Asked Answered
U

3

1

I am working in android. I am designing an application which shows Hindi words in text view.

I am using this code.

        String str="दिव्या";
        TextView txtview_name=(TextView)findViewById(R.id.textViewmyView);

        final Typeface customF = Typeface.createFromAsset(this.getAssets(), "Hindi-SARAL1.TTF");

       txtview_name.setTypeface(customF);

       txtview_name.setText(str);

I used font in my resourses like DroidHindi.ttf, DroidSansFallback.ttf etc. this is showing some words correctly like as समर, राजा etc , but this does not show correctly words like as दिव्या So please suggest me what .ttf i should use so each word of Hindi show correctly.

Ultramarine answered 26/4, 2012 at 8:10 Comment(1)
Though the thread is 2 years old, maybe https://mcmap.net/q/912247/-android-2-x-devanagari-unicode-issue is same as this thread.Pelagia
M
1

@Pushpendra I was having same problem with my testing device (HTC phone). But i tried same app on samsung android phone it works properly on it. So i think you should try your app on different device May be this will help you.

Mideast answered 29/3, 2013 at 7:27 Comment(0)
H
0

Instead of .ttf file, use .otf file.

Homebody answered 26/4, 2012 at 9:3 Comment(0)
T
0

you can use Unicode instead of direct value...

String str="&# 2367;&# 2342;&# 2357;&# 2381;&# 2351;&# 2366;";

continious no gap.

TextView txtview_name=(TextView)findViewById(R.id.textViewmyView);

final Typeface customF = Typeface.createFromAsset(this.getAssets(), "Hindi-SARAL1.TTF");

txtview_name.setText(Html.fromHtml(""+str));
txtview_name.setTypeface(customF);

and you can also convert world to unicode via this site...http://mylanguages.org/converter.php but in case of दि use 1st unicode of इ then 2nd द ..b/c till android 4.0 not support proper Hindi unicode..&# 2342; is unicode of द.

Toluene answered 2/5, 2013 at 17:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.