I want to display Telugu font in android In 4.0 and above devices Telugu font will support automatically but I have problem in 4.0 below devices.I have used following code but Telugu is not rendering properly.
Typeface tf= Typeface.createFromAsset(this.getAssets(), "fonts/gautami.ttf");
TextView telugu=(TextView)findViewById(R.id.telugu);
telugu.setTypeface(tf);
telugu.setText("హైదరాబాద్");
Please help me on this. Thanks in advance.
remove /font to solve your problem
You can use a subfolder called fonts but it must go in the assets folder not the res folder.
assets/res
Android
TextView telugu = (TextView) findViewById(R.id.telugu);
Typeface Typefacetf = Typeface.createFromAsset(getAssets(), "gautami.ttf");
telugu.setTypeface(Typefacetf);
telugu.setText("హైదరాబాద్");
Just define your font in string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="text_your_name">హైదరాబాద్</string>
</resources>
because in that encoding is utf-8 is there so it will render properly.
now for setting that text you can use this:
telugu.setText(getResources().getString(R.string.text_your_name));
EDIT:
Now see answer over here it may help you out :: stackoverflow they having same problem like you.
Write a item inside string.xml inside values folder
<string name="your_text">హైదరాబాద్</string>
Then keep your font file in assets folder
Then create custom typeface in java code using font from assets folder
Typeface custom_type_face = Typeface.createFromAsset(getAssets(), "gautami.ttf");
Use this to your TextView
TextView telugu = (TextView) findViewById(R.id.telugu);
telugu.setTypeface(custom_type_face);
Set Text from strings.xml folder
telugu.setText(getResources().getString(R.string.your_text));
Related
I'm new to Android field . I have followed the procedure of getting Hindi fonts on emulator but still Hindi characters are appearing in square boxes. Please help me how to proceed. I m using android 2.2 ,juno version. Any help regarding above problem will be highly appreciated.
Set The Hindi Font on TextView in Android
TextView t = new TextView(this);
Typeface Hindi = Typeface.createFromAsset(getAssets(), "fonts/mangle.ttf");
t.setTypeface(Hindi);
t.setText("Naveen Tamrakar");
Android does not yet fully support Hindi (droid fonts):
Read this link.
Create a folder in assets as "fonts".
Place your .ttf file of font in that.
then try the code as :
Typeface fontHindi = Typeface.createFromAsset(getAssets(), "fonts/font.ttf");
tv.setTypeface(fontHindi);
It works for me. Hope it works for you too.
You can download hindi fonts from http://hindi-fonts.com and copy it in /system/font directory of your phone. The font will be installed.
First of all download hindi font, d the OTF/TTF file you get, save that in asset folder, eclipse has already the folder, if you are using android studio, then make a new folder in project/app/src/main.
Then in java file, suppose you have to apply your font on TextView t1, use the code..
Typeface mytypeface= Typeface.createFromAsset(getAssets(),"font-file_name.TTF");
t1.setTypeface(mytypeface);
This way you can use Hindi font in Android.
Step 1: Add All Hindi text in res --> values --> string.xml file
<resources>
<string name="app_name">गन्ने से समृद्धि</string>
<string name="ganne_ki_kheti">गन्ने की खेती</string>
<string name="sampark">संपर्क</string>
Step 2: In layout xml file add text tag as android:text="#string/your_text".
For Example see below.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="32dp"
android:text="#string/ganne_ki_kheti"
android:textSize="32sp"
android:textStyle="bold" />
I am doing like this but it get force close. I want to change textview font.
TextView mWeddingDataandTime=(TextView)findViewById(R.id.wedding_weddingtime_txt);
Typeface face=Typeface.createFromAsset(getAssets(),"fonts/CURLZ_.otf");
mWeddingDataandTime.setTypeface(face);
I am using .otf file. It is in assets folder. Any idea?
Try this:
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "Chantelli_Antiqua.ttf");
txt.setTypeface(font);
Note that file extension is "ttf" search in google for any font for download in this extension
for example:
http://www.creamundo.com/
In code you are using fonts/CURLZ_.otf as path but you say that font file is directly inside assets so your code should be
Typeface face=Typeface.createFromAsset(getAssets(),"CURLZ_.otf");
if there is no fonts folder inside assets folder.
I didn't test it but I think it may help you:
TextView mWeddingDataandTime=(TextView)findViewById(R.id.wedding_weddingtime_txt);
Typeface face=Typeface.createFromAsset(getAssets(),"fonts/CURLZ_");
mWeddingDataandTime.setTypeface(face);
If your font is only in asset folder not in asser/fonts forlder than use this
Typeface face=Typeface.createFromAsset(getAssets(),"CURLZ_.otf");
Below is code which I used in my project & it's working... You might need to do some changes
Typeface myTypeface = Typeface.createFromAsset(this.getAssets(),"segoeuil.ttf");
TextView loantext = (TextView)findViewById(R.id.loantext);
length1.setTypeface(myTypeface);
1) Put font in assets folder instead of fonts folders
2) instead of getAssests() in you code use "this.getAssets()" or "youractivity.this.getAssets()
Thank You
Better to make use of the styles and themes and inbuilt fonts for performance related and size of the app related issues Styles & Themes
I am creating an app which uses math fonts like lambda,integral etc in android. And how could i use an keyboard for that? plz help nothing found on google
If you have a .ttf font file with your symbols, place it in the /assets folder then use it on a TextView like this:
Typeface font = Typeface.createFromAsset(getAssets(), "font.ttf");
TextView tv = (TextView) findViewById(R.id...);
tv.setTypeface(font);
As for using the keyboard see:
http://www.addictivetips.com/mobile/create-your-own-custom-keyboard-for-android-devices/ and creating custom android keyboard layout
I want to change the font face and styles in android. How to do this? Am using emulator. Is this possible to change in emulator. Is there any permissions available to do that. Thanks in Advance.
in android only five fonttype-face
TypeFace
Typeface.DEFAULT
Typeface.MONOSPACE
Typeface.SANS_SERIF
Typeface.DEFAULT_BOLD
Typeface.SERIF
and font-type
Typeface.NORMAL
Typeface.BOLD
Typeface.BOLD_ITALIC
Typeface.ITALIC
you can use like as
textView.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
and other way is you can download any .ttf file and put it in asset folder and use like as this
Typeface type=Typeface.createFromAsset(context.getAssets(),
"DroidSansMono.ttf");
textView.setTypeface(type, null);
You can change the font style and font face in your XML files. For example if you want to change your Button's style and face. Choose your button in xml and follow the below methods :
Button -> Right Click -> Properties -> Typeface and style
Hope this will help you.
If you want to change in code ;
This is good reference;
http://mobile.tutsplus.com/tutorials/android/customize-android-fonts/
what you want?. Do you want to change the font face and styles of text in textview. if yes then use this
Typeface type = Typeface.createFromAsset(this.getAssets(),"your font name");
text.setTypeface(type);
and for styles use these links:
Style-resource
Themes
If you want to use a font which is not default (like "Helvetica") for the text in Android application then put the font file(Helvetic.ttf) in assets folder and do use this code as below:
Typeface tf= Typeface.createFromAsset(getAssets(), "Helvetica.ttf");
TextView mTextView =(TextView) findViewById(R.id.text);
mTextView.setTypeface(tf);
if u want to use custom font jus download .ttf file and put the file into assets folder
and use like this:
TextView tv=(TextView)findViewById(R.id.textView);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/arial.ttf");
tv.setTypeface(tf);
I am trying to use custom font in android. I have written java code as given below.
TextView txt = (TextView) findViewById(R.id.customfont);
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Molot.otf");
txt.setTypeface(font);
where I have stored the custom font in "./assets/fonts/" folder.
But, I am getting nullpointerexception on the 3rd line.
Can anybody give me the solution for this issue? Thanks
Android supports only TTF font type not OTF. Check this link
"RuntimeException: native typeface cannot be made" when loading font
Android supports OTF as well. Your font may be corrupt.
Download delicious font from www.exljbris.com/delicious.html. It is an otf font and it works for me.
Try this
Typeface font = Typeface.createFromAsset(getAssets(), "/fonts/Molot.otf");