1

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.

hcp
  • 279
  • 1
  • 5
  • 13

3 Answers3

1

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("హైదరాబాద్");
Jaykumar Patel
  • 26,836
  • 12
  • 74
  • 76
0

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.

Community
  • 1
  • 1
Kishan Dhamat
  • 3,746
  • 2
  • 26
  • 36
0

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