Rendering HIndi font on Android 2.3 and lower - android

I am developing an android App in Hindi but find that few characters are misspelled and broken in Hindi the issue is in http://code.google.com/p/ankidroid/issues/detail?id=1008 but no solution there दिप is rendered as दपि
letters in hindi font above are formed as द + ि + प which should display as दिप but It render as दपि
The same question was put earlier but not resolved so I had to repost it again
Correcting Hindi (Unicode) rendering in Android

Finally I found the solution this is very simple just import the font in my case I am developing web app
#font-face { font-family: hindi; src: url('fonts/k010.TTF'); }
body,h1,h2{ font-family:hindi; }
then type text in your a text editor or MS-word using Kruti devi10 font after You finished change the font to Arial and paste the text in your web App and it will render perfectly

you can use Unicode ...
TextView tv=(TextView)findViewById(R.id.textViewmyView);
final Typeface tf = Typeface.createFromAsset(this.getAssets(), "Hindi-SARAL1.TTF");
tv.setText(Html.fromHtml("&# 2367;&# 2342;&# 2346;"));
tv.setTypeface(tf);
unicode value continues no gap.....
and you can also convert world to unicode via this site...http://mylanguages.org/converter.php but in case of इ 1st use unicode of इ then alphabets Unicode...b/c till android version 4.0 Hindi Unicode not supported proper..

Related

how to make gujrati font supported in android app

i'm going make a web site in which i have lots of Gujarati language text.
i found that in many cell phones (Micromax canvas2,etc) Gujarati language is not supported.
so i'm thinking to make a web browser in android which support Gujarati font. so user can use that my web site through my android browser.
plzz help me quickly
Few devices doesn't support Gujarati language packs.
You need to define css and apply it to your webview.
Below post may help you as well.
Android 2.2 webview not supporting Tamil font
Hi Try this this will work fine
TextView mtxt = (TextView) findViewById(R.id.action_settings);
Typeface face1 = Typeface.createFromAsset(getAssets(),
"Lohit-Gujarati.ttf");
mtxt.setTypeface(face1);
mtxt.setText("પૂર્વ વડાપ્રધાન રાજીવ ગાંધીની હત્યા કરનારા 3 આરોપીઓની ફાંસીની સજા સુપ્રિમ કોર્ટે ઉમ્રકેદમાં ફેરવી નાંખી છે.આમ રાજીવગાંધીના" +
"3 હત્યારાઓને હવે ફાંસીની સજા નહી થાય.સુપ્રીમ કોર્ટમાં 3 જજોની બેન્ચે આજે આ ચુકાદો આ");

Typeface is not rendered in Android

I'm trying to set a font like this:
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/myfont.ttf");
textView.setTypeFace(tf);
However, it works for some fonts like Helvetica, or like that, but as soon as I try to load some other fonts, it ignores my typeface and it loads android's default one.
I've checked a looot of answers, and an user stated
Android at the moment when can't set a typeface, instead of throwing an exception, just places system default typeface.
But this is obviously not an answer.
What can I do?
I've even checked sourcecode of TextView, which leaded me to TextPaint, and TextPaint leaded me to Paint but couldn't really find a solution about my issue.
Help would be sooo appreciated.
Thanks.
But this is obviously not an answer.
Well, grammatically it has issues, but it is the answer. Android has had problems loading fonts since Android 1.0, and the API for Typeface does not report success or failure.
What can I do?
Test your typefaces and see which ones work.
If you have licensed the rights to modify the font, you could try loading it into a font editor and saving it again, to see if it is a question of the format of the font file.
Or, contribute changes to the AOSP to improve typeface handling, then wait a few years for those changes to make it out to the majority of Android devices.
Try typeface using SpannableStringBuilder it will work,,
String stringResult="Your unicode string";
SpannableStringBuilder SS = new SpannableStringBuilder(stringResult);
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/myfont.ttf");
if(tf != null)
{
SS.setSpan (new CustomTypefaceSpan("", tf), 0, stringResult.length(),Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
}
textView.setText(SS);

Correcting Hindi (Unicode) rendering in Android

I successfully added a custom typeface (DroidSansFallBack.ttf) to show Hindi characters instead of Blocks on Pre ICS . All is working well on 4.1+ in any case.
But the rendering order is wrong on Froyo and Gingerbread.
I understand it is not resolved http://code.google.com/p/android/issues/detail?id=4153
What are the possible workarounds to correct the rendering? (I don't want to use images )
EDIT:
Example,
दिन string from values-hi renders as दनि
नक्षत्र renders as नक् ष त र
(On 4.1+ everything renders correctly)
I have a alternative solution for your problem but not exact...
use font....
Typeface tf = Typeface.createFromAsset(getAssets(),"Hindi-SARAL1.TTF");
for नक्षत्र use .......
TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText("n95");
tv.setTypeface(tf);
and for दिन........ unicode value continues no gap.. i have given a space between &# and 2367;
tv.setText(Html.fromHtml("&# 2367;&# 2342;&# 2344;"));
tv.setTypeface(tf);
I could not find a simple work around for fixing the rendering everywhere. So finally I had to limit the Hindi language feature to devices having android version 4.0 or later.

Why 'ARABIC LETTER PEH' is not shown correctly on Android 3.x?

In Unicode characters the ARABIC LETTER PEH INITIAL FORM 'ﭘ' is 0xFB58. When I use the following code to show Unicode characters, everything is OK for every Unicode character in Android 2.2, 2.3. and 4.x But I have problem with ARABIC LETTER PEH 'ﭘ' on Android 3.x and in this case character '~' is shown.
Typeface tf = Typeface.createFromAsset(context.getAssets(),"TAHOMA.TTF");
strChars = "";
strChars += (char) 0xFB58;
tvChars.setTypeface(tf);
tvChars.setText(strChars);
I should mention that The problem is remained when I change the font or ignore using setTypeface(tf)
Why?
How can I find the code of ARABIC LETTER PEH in Unicode?
EDIT:
Please compare 0xFB58 (ﭘ) and 0xFB5E (ﭞ) with any font programmatically. you will find the problem. the first one is not shown but the second one is shown correctly.
Did you try adding your own fonts?
Get a Persian TTF font file that fits you and use it, this way you won't be OS dependent.
http://twigstechtips.blogspot.com/2012/01/android-how-to-use-true-type-fonts-ttf.html

Issue in custom font (RTL labguage)

According to android 2.3 some RTL languages such as Arabic is supported in this new version. However, emulator does not show the fount correctly. In code I have written:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView txt = (TextView) findViewById(R.id.myText);
Typeface font = Typeface.createFromAsset(getAssets(), "Larabieb.ttf");
txt.setTypeface(font);
txt.setTextSize(26);
txt.setText("السلام علیک یا حبیبی");
}
but in the output it shows separated characters instead of connected characters.
How can I connect the characters?
As of this date only Samsung's phones running on android support bidi and display of arabic characters. There is nothing wrong with your code. Open the web browser and browse an arabic website you will see the same problem on non-samsung phones.
you can use this tools
Tools.fa("سلام علیکم");
sample image:

Categories

Resources