how to use font family like professional in android studio - android

Is, any professional font family available on android. If it is not available, then how to use professional fonts in android. Thanks in advance

You can flow this step:
1.Go to the (project folder)
2.Then app>src>main
3.Create folder 'assets>fonts' into the main folder.
4.Put your 'abc.ttf' into the fonts folder.
AssetManager am = context.getApplicationContext().getAssets();
typeface = Typeface.createFromAsset(am,
String.format(Locale.US, "fonts/%s", "abc.ttf"));
setTypeface(typeface);

To add a font to your App, place the font file in asset folder and use the following code to set it to text view...
TextView textView = (TextView) findViewById(R.id.textView);
Typeface typeFace = Typeface.createFromAsset(getAssets(),
"fonts/digital.ttf");
textView.setTypeface(typeFace);

to get the fonts follow this link.
https://fonts.google.com
These are the google recommended fonts.

Related

How can I set chosen font in textview

I have a question. How Can I set font for example: Harrington in textview. I use:
Typeface type = Typeface.createFromFile("C:/Fonts/Kokila.ttf");
gameResult.setTypeface(type);
gameResult = (TextView) findViewById(R.id.textViewResult);
but this solution is not working. Any ideas?
first place your font in assets folder then like:
gameResult = (TextView) findViewById(R.id.textViewResult);
Typeface type = Typeface.createFromAsset(getAssets(),"fonts/Kokila.ttf");
gameResult.setTypeface(type);
You are trying to access the font from your PC! Your phone does not have access to the 'C:/' drive of your PC, and therefore cannot load the font. You need to place the Font into the Assets folder of your application, and then read it from there.
You can read a file from the Assets folder using
context.getAssets().open(fileName);

How to set gujarati for textview in the android application?

I want to make a application in which i needs to show the textview in gujarati language.
I tried with
Typeface tf = Typeface.createFromAsset(getAssets(), "G-SARAL1.TTF");
text.setTypeFace(tf);
but this is not working, I set the gujarati text in string.xml file and then i set that string in the textview, but when i run the application, it display square boxs instead of gujarati character,
can anyone help me , how can i implement this task.
As gujarati and hindi languages are not supported by Android, you can still give that support to your Application.
For Gujarati copy the C:\WINDOWS\Fonts\Shruti.TTF file to your asset folder. Then use the following code.
TextView text_view = new TextView(this);
Typeface font = Typeface.createFromAsset(getAssets(), "Shruti.TTF");
text_view.setTypeface(font);
text_view.setText("ગુજરાતી");
Shruti.TTF file is for Gujarati font. Similarly you can add support for hindi file.
Try this code this will work
TextView mtxt = (TextView) findViewById(R.id.action_settings);
Typeface face1 = Typeface.createFromAsset(getAssets(),
"Lohit-Gujarati.ttf");
mtxt.setTypeface(face1);
mtxt.setText("પૂર્વ વડાપ્રધાન રાજીવ ગાંધીની હત્યા કરનારા 3 આરોપીઓની ફાંસીની સજા સુપ્રિમ કોર્ટે ઉમ્રકેદમાં ફેરવી નાંખી છે.આમ રાજીવગાંધીના" +
"3 હત્યારાઓને હવે ફાંસીની સજા નહી થાય.સુપ્રીમ કોર્ટમાં 3 જજોની બેન્ચે આજે આ ચુકાદો આ");
You can download the Montserrat fonts, this font is use for both language English and Gujarati. If you do not want to download the saperate fonts than can use this. You can make base text and can create method like below and use the fonts. One more thing you have to pass the
fun setFonts(context: Context, fontName: String) {
val typeface = Typeface.createFromAsset(context.assets, fontName)
setTypeface(typeface)
}
To create localized string file you can also use Translations Editor.
I checked out all the given solutions but no one solved my prob
so I did some more and more google and found out that, you need to create assets folder first
and then paste all the fonts file which you required in your application
here is a little guide for how we can add assets folder in our project
Step 1 : Navigate to the top left side of an android studio where you got menu like this and just change the option from the dropdown to Packages
Step 2 : now you will see parent as app and now just right click on the app and click new and then Folder and then Assets Folder
this is how you can add Assets Folder.
once you add Assets Folder then simply paste your ttf files into that Assets folder.
and follow my code for reference
TextView text_view = (TextView) findViewById(R.id.txtMsg);
//TextView text_view = new TextView(this);
Typeface faceShruti = Typeface.createFromAsset(getAssets(),
"shruti.ttf");
text_view.setTypeface(faceShruti);
text_view.setText("In Gujarati\n" + "સ્વાગત");

how to use tamil font in android

this is my tamil UTF-8 unicode string
"\u00e0\u00ae\u009c\u00e0\u00af\u0086\u00e0\u00ae\u00a9\u00e0\u00ae\u00bf\u00e0\u00ae\u00b2\u00e0\u00ae\u00bf\u00e0\u00ae\u00af\u00e0\u00ae\u00be \u00e0\u00ae\u00aa\u00e0\u00af\u0081\u00e0\u00ae\u0095\u00e0\u00af\u0088\u00e0\u00ae\u00aa\u00e0\u00af\u008d\u00e0\u00ae\u00aa\u00e0\u00ae\u009f\u00e0\u00ae\u00ae\u00e0\u00af\u008d"
i want to decode it and display the tamil font
in android is this posible,how to do ?
please help me
You can save the tamil (ttf) font in the assets folder, and use it like this:
TextView text; // initialize to your textview
Typeface tf = Typeface.createFromAsset(this.getAssets(),"fonts/tamil.ttf");
text.setTypeface(tf);
Step 1: Download a tamil font .ttf file. (For example say kanchi.ttf).
Step 2: Now create a directory "fonts" in your assets folder in the android project.
Step 3: Now copy the kanchi.ttf file into assets/fonts folder in you Android project.
Step 4: Add these lines to your onCreate()
protected static Typeface tamil = null;
tamil= Typeface.createFromAsset(getAssets(),"fonts/kanchi.ttf");
Step 5: Now provide this typeface to your TextView you want.
textview= (TextView) findViewById(R.id.tipstext);
textview.setTypeface(tamil);
textview.setTextSize(20);
textview.setText( "nkZk;");
The best way to display tamil in android is to use TSCII font as described here. Unicode is not yet fully supported.
if you are using webview, place the your font file 'tamilfont.ttf' in the assets folder.
and the java code will be similar to this. notice the font is applied in the css
data = "<html><head><style>#font-face {font-family: 'tamilfont';src: url('file:///android_asset/tamilfont.ttf');} h1 { font-family: 'tamilfont'; } </style></head><body> <h1>தமிழன்!</h1> </body></html>";
WebView wv = (WebView)findViewById(R.id.webview);
wv.loadDataWithBaseURL(null, data, "text/html", "UTF-8", null);
this approach does not work in android 2.0 and 2.1.
I Have one to open Tamil font convert doc to pdf and then try to open in android phones

Android Application to Install a font

I wanna create an application in android to install a Hindi Font. Can some one guide me how i can go about it ? is it possible ?
Add the font file you want to use in the assets folder of your Android application. Then you can load the font and use it like this:
AssetManager assetManager = getContext().getAssets();
Typeface tf = Typeface.createFromAsset(assetManager,"GILB.TTF");
TextView logo = (TextView)findViewById(R.id.logo);
logo.setTypeface(tf);
In this case, I've used the true type font Gill Sans Bold.
You cannot install a font on a device.
You can package a font as an asset with your application to be used by your application.

Android develop LCD font

How to add additional font in android environment? I need to make a font like LCD with pale background numbers like this:
http://www.androidfreeware.net/img2/gps_speedometer_android_1.png
We at bangalore android developers group had done this for one of our project AutoMeter You can have a look at the code there in detail.
The code would look something like this
Typeface myTypeface = Typeface.createFromAsset(this.getAssets(),"DS-DIGIB.TTF");
waitingTimeView = (TextView) findViewById(R.id.WaitingTime);
waitingTimeView.setTypeface(myTypeface);
DS-DIGIB.TTF is the font put in the assets folder
public void setFontTextView(Context c, TextView name) {
Typeface font = Typeface.createFromAsset(c.getAssets(),"fonts/Arial.ttf");
name.setTypeface(font);
}
Download Arial font in ttf file formate and put in asset folder. Thats enough.
You want to use the android.graphics.Typeface class, which can create new Typefaces from assets or files.

Categories

Resources