Flutter is breaking the Arabic font in my android app. How can I fix this issue
The font you are using is not supporting well Arabic, you need to choose an Arabic font.
The problem is. I was using letter spacing in the text widget and also I have to add the style property of the Text widget in order to fix this issue.
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?
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 ?
I need to use tamil on textviews in my app so I create a TypeFace from
assets and set it to the textview, but the characters appear out of order(mixed) for combined characters. I load the strings from the resources.(string.xml in utf-8 encoding)
How to solve this issue?
Currently android does not have a tamil font Shaping Engine. So have to manually reorder the characters based on the tamil language rules.
use fonts like "Bamini.ttf" else some TSCII fonts. It works fine for me. It should work for you too.