I am currently working on an android application which needs Gujarati font support. I have tried the typeface method but all in vain. I tried to find the solution on internet but didn't quiet get the solution.
I am using recycler view in which I need to display the text view using Gujarati fonts.
I kindly request you to help me with this.
Thanx in advance .... :):)
Here is the method i used to add custom gujarati fonts in the ViewHolder method of RecyclerView
public ViewHolder(View v) {
super(v);
mNameTextView = (TextView) v.findViewById(R.id.nameTextView);
Typeface tf = Typeface.createFromAsset(v.getContext().getAssets(), "fonts/guj.ttf");
this.mNameTextView.setTypeface(tf);
this.mNameTextView.setTextColor(Color.DKGRAY);
}
Finally got the Solution. All i needed was the official google NotoSansGujarati font which can be downloaded from the given link.
https://www.google.com/get/noto/
public ViewHolder(View v) {
super(v);
mNameTextView = (TextView) v.findViewById(R.id.nameTextView);
Typeface tf = Typeface.createFromAsset(v.getContext().getAssets(), "fonts/NotoSansGujarati-Bold.ttf");
this.mNameTextView.setTypeface(tf);
this.mNameTextView.setTextColor(Color.DKGRAY);
}
If you're using Android 5.0 (Lollipop), Google has added fonts.
The fonts are called Noto Sans Gujarati and Noto Sans Gujarati UI.
As you're working on an application, that has to be compatible for all the Android Versions, you have to root the particular device for that to work on.
Reference 1
Reference 2
Related
So, I am making a Game called Fall Down 4 and currently I am just using the built in font (the font that it usually comes with). Now, I want the Title to look more attractive and Good and to do that, i actually downloaded different fonts from Google. I Then created a assests folder and in that folder i copied the font that i installed in my computer (I looked at the different forums on stack overflow). Now my question is how Do i Change the default font to this new downloaded font. Like I just Don't know where to go to change the font of the Text.
I have seen many people ask this question on this fourm but what i want is different FONTS, a FONT that is not BUILT IN, i wannt to USE the FONT I DOWNLOADED and That is what I need help With.
So Please tell me step by step on how to change the font of the text to the font That I have installed in my computer.
The Code:
public class FallDown4TitleScreen extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fall_down_title_screen);
Typeface myTypeFace = Typeface.createFromAsset(getAssets(), "Spac3 tech free promo.ttf");
final Button playbutton = (Button) findViewById(R.id.Playbutton);
final Button custButton = (Button) findViewById(R.id.custButton);
final Button settingButton = (Button) findViewById(R.id.settingButton);
final TextView textView = (TextView) findViewById(R.id.textView);
textView.setTypeface(myTypeFace);
playbutton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
custButton.setVisibility(View.INVISIBLE);
settingButton.setVisibility(View.INVISIBLE);
textView.setVisibility(View.VISIBLE);
playbutton.setVisibility(View.INVISIBLE);
}
});
}
}
If you are looking to set a custom TrueType font from your asset folder to some textviews or similar views, you could simply do like:
textview.setTypeface(Typeface.createFromFile(getAssets(),"fonts/yourfont.ttf"));
take a look at this discussion if you are looking to change the default font in your app:
Is it possible to set a custom font for entire of application?
However, mobile games generally use bitmap fonts, and draw that on canvas.
Hope that helped!!
Im trying to apply typeface to textviews and editTexts but the typeface silently fails with no error or exception in logs.There is no change in font and android default font is shown.
I have tried around 10 fonts nothing works(otf & ttf both) nothing worked
I also tried to convert it http://www.freefontconverter.com/ here as some answers suggested. But, still not working.
typefaceLight = Typeface.createFromAsset(getAssets(), "fonts/MyriadProRegular.otf");
// typefaceBold = Typeface.createFromAsset(getAssets(), "fonts/HNBold.otf");
// typefaceBold = Typeface.createFromAsset(getAssets(), "fonts/Helvetica.ttf");
typefaceBold = Typeface.createFromAsset(getAssets(), "fonts/HelveticaBold.ttf");
typefaceLight = Typeface.createFromAsset(getAssets(), "fonts/HelveticaLight.ttf");
typefaceArialBold = Typeface.createFromAsset(getAssets(), "fonts/helveticabold1.ttf");
// typefaceLight = Typeface.createFromAsset(getAssets(), "fonts/HNLight.otf");
registerTitleTv.setTypeface(typefaceBold);
signInTittleTv.setTypeface(typefaceBold);
termsSiginTextView.setTypeface(typefaceLight);
termsSignUpTextview.setTypeface(typefaceLight)
I have referred to
Custom Fonts not working in lollipop?
Custom Font not working on Android
Changing the android typeface doesn't work
https://code.google.com/p/android/issues/detail?id=61771
Android 5.0 (API 21) fails to render custom fonts / typefaces
Is there something wrong with my code?
your code seems fine . I would suggest you either clean your code or uninstall app and install again .
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'm already working on an Android application that displays RSS feed.
My problem is that this feed has some lines in Tamil(which Android still doesn't support)
I found a font online that displays the text right(without converting to Bamini) but the problem is that textStyle doesn't have any effect on it.
so you know any font that can do the job or any thing i have to do to make textStyling?
thanks in advance
What you need to do is import custom fonts on to the phone before using them.
A good way to do that is to include them in the package - in the APK file
Hence you should be having the font in your project when you build the APK file.
Let me give you an example. Assuming your tamil font's name is Harabara.ttf and you have copied it to /assets/fonts
Use this method (anywhere in your activity)
private void initializeFonts() {
font_harabara = Typeface.createFromAsset(getAssets(), "fonts/Harabara.ttf");
}
and call this API from your onCreate like this
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initializeFonts();
setContentView(getViewResourceId());
}
Make sure you have declared this class level variable
Typeface font_harabara = null;
Finally, simply use
myTextField.setTypeface(font_harabara);
tada ! tamil font should now start displaying.
nandri vanakkam,
vaidyanathan
There are hundreds of fonts available online. Did you check some TSCII fonts?
I've written some solutions for Tamil and Android issues. Check it out too.
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: