Android Application to Install a font - android

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.

Related

how to use font family like professional in android studio

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.

I am developing an Android app which contains fonts from regional languages do i require fonts.ttf file

I am developing an android app where I will be consuming a json which contains Hindi fonts but without using .ttf file.I was able to bring the fonts to the UI in the AVDemulator It works fine but is it correct way or any other procedure is there to bring Hindi fonts.
Most of the android devices distributed in India supports Hindi font by default. But still if you want to have any custom hindi font then you must have to add .ttf font file into your asset folder and set it to textview. Use below function to read font file from asset folder
static public Typeface getTypefaceFromAsset(String strName, Context context)
{
Typeface typeFace = Typeface.DEFAULT;
try
{
AssetManager assetManager = context.getAssets();
typeFace = Typeface.createFromAsset(assetManager, strName);
} catch (Exception e)
{
e.printStackTrace();
}
return typeFace;
}
Yes! you require the .ttf file for font then add your font.ttf file in assets folder and set font like this
for ex:
txtFirstName.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "fonts/hindifont.ttf"));

How do you integrate custom fonts in an app?

I am trying to integrate custom fonts (Imperator.ttf and goodfish.ttf) from the following website into my corona app:
http://www.1001freefonts.com/top-fonts.php
I am following carefully the tutorial found here on Corona's official website:
http://www.coronalabs.com/blog/2013/01/16/faq-wednesday-custom-fonts/
I follow the whole procedure for macosx integration (installing the font by double clicking etc) and do not get any error. I also added the font file name to my build.settings file:
UIAppFonts =
{
"Imperator.ttf"
},
Whenever i launch the simulator and debug the currently loaded fonts, the new one doesn't appear.
Is there an easy way to debug the issue on corona simulator, on osx, to troubleshoot why the font doesn't load ?
Thanks
While installing custom fonts to your corona application, you have to follow the following steps:
Install the font in your system.
Copy and paste the font file(such as: Imperator.ttf) to the application folder where your main.lua exists.
Then for iPhone(only for iPhone, Android doesn't need this), add the following lines to your build.settings:
iphone =
{
plist =
{
UIAppFonts =
{
"Imperator.ttf" -- Font file name
},
UIApplicationExitsOnSuspend = true
},
}
Debug and get the supported Font Names by the system using the following:
local fonts = native.getFontNames()
for i,fontname in ipairs(fonts) do
print(fonts[i])
end
From the above debugging, you can get the exact Font Name (here: Imperator) that you have to use while creating the text/label. Sometimes this may differ from the name of the font file. You can also get it from applications like photoshop(it's text tool font name), etc.
local myText = display.newText("Label with custom font",150,100,"Imperator",20)
Then finally, you will get the output as:
Keep coding................ ๐Ÿ˜ƒ
Put Imperator.ttf font file in Assets folder
In class use following code:
Typeface imperator_typeface =Typeface.createFromAsset(getContext().getAssets(),"Imperator.ttf");
your_textview.setTypeface(imperator_typeface);

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" + "เชธเซเชตเชพเช—เชค");

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