How to get Hindi fonts in Android..? - android

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" />

Related

Custom font not showing on device

I am trying to add a custom font following the "Fonts in XML" tutorial on this site. I followed the tutorial to the letter and checked many times to find something I missed but I just can't see it. The font I added is a TTF file.
In the designer, I can select my font family and the text in the TextView changes to the custom font I added. However, when I run the app on my device, the text is defaulted to the regular font. This doesn't happen with the fonts included in Android Studio.
Additional question: when I tried yet another custom font, the text in the TextView changed to the custom font, but the text itself (the content) also changed to some gibberish. Is this an indication of a bad font or something else?
sv_regular.xml
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="400"
android:font="#font/sv_font_regular" />
</font-family>
TextView
<TextView
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/sv_regular"
android:text="#string/app_name" />
You can do this programmatically
Add external fonts in your assets folder
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.
TextView tx = (TextView)findViewById(R.id.textview1);
Typeface custom_font = Typeface.createFromAsset(getAssets(),"fonts/abc.ttf");
tx.setTypeface(custom_font);
I have encountered such a problem when the font is displayed in Android Studio but does not work on a physical device.
So if you want a custom font from Android Studio to be displayed on your phone screen, you need to add this font to your project as follows:
Open res folder.
Create Android Resource Directory. Resource type - font. You can also name your new folder font.
Then simply drag and drop your ttf font into the font folder. Important: The font name must not contain prohibited characters, and all letters in the name must be lowercase. The name of my font in this example: kopenhagen
(you may have a different font name).
Open your xml file, find the text in which you want to change the font, and just add the following:
android:fontFamily="#font/kopenhagen"
*Instead of the word kopenhagen, use the name of your font
Does your font exactly support the language of the text? This problem occurs when the font does not support certain characters, such as Cyrillic. And one more: try use sv_font_regular in TextView
android:fontFamily="#font/sv_font_regular"
Example

Custom Fonts not working in lollipop?

I have developed a handwriting app .And one of the main feature of this is that we can change the fonts from default font to 4 other custom fonts ie, to
Vicmorg (Vic Modern Cursive)
Cursive Writing 7
Dnealiancursive
Print-Regular
And this is working fine in all devices.Yesterday I updated my nexus 10 to lollipop .Now the fonts are not taken correctly, vicmorg.ttf and Dnealiancursive.ttf are now not working but Print-Regular and Cursive Writing 7 are working .No issues in other phones though. Is there a fix for this ? Please help.
re-convert your whatever fonts to .ttf from this link works for me.
http://www.freefontconverter.com/
I did it in following way:
I have updated TextView with androidx.appcompat.widget.AppCompatTextViewand it works for each device.
Example
From
<TextView
To
<androidx.appcompat.widget.AppCompatTextView
Hope it helps you.
Error on lollipoop
test files .otf run correctly but .ttf not.
my solution for files .ttf was convert to .otf
http://www.files-conversion.com/font-converter.php
or
http://www.font2web.com/
for custom font for example, inside assets folder (../assets/fonts/birdman-webfont.otf):
Typeface birdman = Typeface.createFromAsset(getAssets(), "fonts/birdman-webfont.ttf");
TextView text= (TextView) findViewById(R.id.text);
text.setTypeface(birdman);
note: if your file is .ttf and show ERROR in the convertion, change the extension to .otf manually and convert with http://www.files-conversion.com/font-converter.php

How to display telugu font in android

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));

How to show arabic text in android?

I want to show Arabic text from text file in android. in some phones and tablets it seems to be correct, but on some android devices it looks like the below text:
ا ل س ل ا م ع ل ي ك م
Please help me how to show them correctly on every device.
I assume that the problem here is that the text is not shown right-to-left. You should try using the Bidi class, or by specifying the following in your XML:
<EditText android:layout_width="match_parent" android:layout_height="wrap_content"android:id="#+id/editText1" android:gravity="right">/EditText>
Copy the ttf file to the assets folder in your android project folder..Then set the typeface of the textview in the code.

How do I show Malayalam (an Indian language) on android?

I have an app that must show some Malayalam text. I used some Malayalam fonts and tried to use that through typeface. Though all the characters are shown, some of the symbols are not shown or are displaced. I use android 2.2. Can anyone guide me to solve this problem?
As Malayalam fonts are not supported by Android, you can still give that support to your Application.
For Marathi font copy font file to your asset folder. then use the following code.
TextView text_view = new TextView(this);
Typeface font = Typeface.createFromAsset(getAssets(), "MalayalamFont.ttf");
text_view.setTypeface(font);
text_view.setText("മലയാളം");
the same way u can give support for hindi....
We can add font files to the assets folder and from there we can load it. here is useful link for you..
Display malayalam text in my app

Categories

Resources