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:
Related
I,m trying to show Sinhala Unicode characters in android app.
when i am using Samsung tabs or phones Unicode is running it on without problem.but it does not work on other phones or tab.cause there is no Sinhala Unicode.How to do this for an example i run this code on Samsung tab successfully.
Toast.makeText(this, "අන්තර්ජාල සම්බන්දතාවය තිබේ ", Toast.LENGTH_SHORT).show();
but other phones or tab does n't work.
You might need to have a Sinhalese font file (say, Sinhalese.ttf) in the directory assets/fonts in the root of your project. You create a dummy text view because it has a method called setTypeface, which sets the font for next code:
import android.graphics.Typeface;
public class FontSampler extends Activity {
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
TextView tv=(TextView)findViewById(R.id.custom); // a dummy text view
Typeface face=Typeface.createFromAsset(getAssets(),
"fonts/Sinhalese.ttf");
tv.setTypeface(face);
Toast.setView(tv).makeText(this, "අන්තර්ජාල සම්බන්දතාවය තිබේ ", Toast.LENGTH_SHORT).show();
}
}
This way, even if an android phone doesn't have a font installed, then the font embedded in your app will serve. Hope this helps.
If you want to render the Both sinhala and English in same text box then use Iskolapota font file.And do the same as #Nonymous answer says. It works for me.
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 જજોની બેન્ચે આજે આ ચુકાદો આ");
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.
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.
I want to create a database in which i can add and retrieve the Urdu words. for this purpose i installed Inpage 2009 professional and copied its fonts (.ttf) into assets folder but it gave an error i.e
I also installed UrduFonts.exe and copied its font JameelNooriNastaleeq.ttf but it also gave the same error. i need the Urdu font that is compatible to the android , the font that can add and retrieve Urdu to and from the database using android.
this is how i coded foa a Lcd2Mono.ttf and i am having the true experience of that font but i am unsuccessful. here is my piece of code..
private EditText txt,start,urdu;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
urdu=(EditText) findViewById(R.id.urdu);
try
{
urdu.setTypeface(Typeface.createFromAsset(this.getAssets(),"urdu.ttf"));
urdu.setText("ur text");
}
catch(Exception ex)
{
start.setText(ex.toString());
}
i did some with Inpage Fonts and got Exception that Native Font.....
i think JameelNooriNastaleeq.ttf font is very huge, more than 10M (maybe somehow connected to your problem), i recommend to try something much more smaller like: http://www.quran.or.kr/urdu/font/asunaskh.ttf
but still issue with connecting the urdu characters, like in this question:
how to add language support to android
what exception you got?