I am developing an android application and I strongly need to use Justify text alignment and also I should use custom font for texts. my application is in Persian language.
If I use TextView for showing texts I cant set text alignment to Justify.
If I use WebView and load html to it I cant use font for it (I know that I can set font using html and css but it does not work for some languages like Persian and Arabic , I tested it, only on android 4.4.2 i see my custom font but on other versions of android webview show android default font)
I tried converting font to SVG but nothings changed.
also I searched in github for a custom webview or textview , I fount one custom textView , both font and text alignment was ok but the direction was left to right but i need it be right to left (I tried changing gravity and other things but cant fix problem).
So what is your suggestion ?
Thank you so much for helping.
Regards.
Take a look at this forum.I used this library with the following attrs and everything works perfectly:
ext:documentView_reverse="true"
ext:documentView_textAlignment="justified"
ext:documentView_textFormat="formatted"
I am trying to change my arabic font in android app and I downloaded several fonts but when I added the below code the arabic letters stayed the same as if the font did not change although I downloaded different fonts with different letters style...
TextView myTextView=(TextView)findViewById(R.id.textView1);
Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/MyFont1.otf");
myTextView.setTypeface(typeFace);
plus I changed the font with a font editor so when I changed the bracket style it appeared as the new style when I added it to eclipse but when I changed a normal arabic letter nothing changed the letter appeared as it is with no modifications...
what's the cause? is there a need to use an arabic reshaper to do that or what's the cause? and how to solve it?
I am working on an Arabic App. I am wondering that my S3 is showing Arabic text correctly. But when I see the text in Emulator it is breaking. Any reason why?
I also faced this type of problem.After I found that for Arabic font we have to use specific type face files like .ttf
You can find some .ttf files which support only for Arabic.
If you're using a TextView to show the Arabic text, try setting the TextView's android:gravity attribute value to "start" rather than "left" or "right". This fixed it for me.
See this question for more possible solutions:
Arabic font gets cut in Android 4.0
i am creating an application and using a custom Arabic font.
When i launch my emulator the Arabic Letter/Characters are separated so its just like the Alphabet?
Is there a Fix for This?
try this
http://mdictionary.wordpress.com/2011/02/10/connected-arabic-characters-for-android-apps/
The screenshot below displays my problem.
The first EditText shows a hint in Arabic which is shifted upwards, now the second EditText is just for reference which shows the English version completely fine. Same goes for the Button.
I have declared the string in strings.xml like this:
<string name="ar_login">دخول</string>
This is how I set the EditText's hint:
UserName.setTypeface(ArabicFont);
String hint = getString(R.string.ar_HintUserName);
....
UserName.setHint(hint);
UPDATE:
I used this, but of no use:
UserName.setGravity(Gravity.CENTER_VERTICAL);
But with this, Text moved a little down; but i guess its not generic:
UserName.setPadding(0,15,0,0);
With Padding, English words move to downwards.
UPDATE 2:
Originally arabic texts are separated; means they are shown letter by letter. So to join them, i was using this Arabic Reshaper. To Download Code, Check this link
Now when i reshape the arabic text and then set on TextView or as EditText's Hint, it got shifted upwords but without reshaping it is fine.
So i guess, whether i have to change the reshape class OR make my textview to not split the word. But dont know where to go?
I am still unable to find out why Android splits the arabic words into separate letters anyhow in my second edit I am providing a link which uses a class to rejoin the separated letters and form a word again.
In the reshape function, it was mistakenly appending \n at the end, just removing it solves the problem.
I am sure its problem with the font file which you are using.!
[Sorry I am not allowed to upload the screen shot as my reputations are lower :(]
For the layout, I was setting text in xml, and typeface in code. And I'm not setting any attributes like padding/gravity. But it was working fine for me.
So, I can assure you that using font file whose style matches your requirement will solve your problem.
Just to help you out with, but 'm not sure I got font file from DroidSansFallback.ttf
Just a guess :) ...,
What if the size of the Arabic font is lower? [If this is the case, then Gravity.CENTER_VERTICAL should have worked for you :( ]
May be this is the style of that font file. How about trying a different font file for Arabic text ?