0

I have a widget layout containing textview. I want to set marathi text to that textview. I am trying ticker widget which shows marathi news on screen. the problem is i am unable to set marathi font to remoteview. Any Help? Thanks in advance

Edited:

Here is My code

RemoteViews remoteViews = new RemoteViews(this .getApplicationContext().getPackageName(), R.layout.widget_layout); 
// Set the text 
remoteViews.setTextViewText(R.id.txt_marqee, stringBuffer);

this is my remoteview inflating widget_layout. And this layout contains textview which i am using as a ticker. I want to set devnagari font to remoteview. Any help?

sl1990
  • 5
  • 2
Rakesh
  • 19
  • 1
  • 3
  • Rakesh, if you have Home Screen Widget Then custom fonts not allowed to use in Home Screen so either use inbuild fonts or generate a bitmap for ImageView. – ρяσѕρєя K Mar 30 '12 at 09:47

5 Answers5

3

As Devanagari 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(), "MarathiFont.ttf");
 text_view.setTypeface(font);
 text_view.setText("मराठी");

the same way u can give support for hindi....

  • RemoteViews remoteViews = new RemoteViews(this .getApplicationContext().getPackageName(), R.layout.widget_layout); // Set the text remoteViews.setTextViewText(R.id.txt_marqee, stringBuffer); this is my remoteview. I ant to set devnagari font to remoteview.Any help? – Rakesh Mar 30 '12 at 09:30
  • pls add the code in the question...i cannot read it in the comment –  Mar 30 '12 at 09:31
  • as Sajid Shaikh said you can only render your font onto a Bitmap in your process, and then push it across RemoteViews. –  Mar 30 '12 at 09:44
0

1)download marathi fonts from website as follows:

http://www.angelfire.com/pop/top4/fonts/

2)apply following code:

TextView info=(TextView)findViewById(R.id.textview);
Typeface face=Typeface.createFromAsset(getAssets(), "fonts/your font.ttf"); 
info.setTypeface(face); 
Harshal Benake
  • 2,391
  • 1
  • 23
  • 40
0

For this you will have to Get a MarathiFont.ttf file, then

Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/MarathiFont.ttf");

and then :

text.setTypeFace(tf);
Bhavin
  • 6,020
  • 4
  • 24
  • 26
0

Dude its so simple Just use follwing line of code

TextView info=(TextView)findViewById(R.id.info);
Typeface face=Typeface.createFromAsset(getAssets(), "fonts/georgia.ttf"); 
info.setTypeface(face); 

Place your font in assets in fonts folder. Work karel. Thanks

Mr. Sajid Shaikh
  • 7,051
  • 4
  • 21
  • 35
  • RemoteViews remoteViews = new RemoteViews(this .getApplicationContext().getPackageName(), R.layout.widget_layout); // Set the text remoteViews.setTextViewText(R.id.txt_marqee, stringBuffer); this is my remoteview. I ant to set devnagari font to remoteview.Any help? – Rakesh Mar 30 '12 at 09:31
  • Because widgets live in other processes, they can only use system typefaces, and not additional fonts that might be internal to your package. One way around this would be to render your font onto a Bitmap in your process, and then push it across RemoteViews. http://www.mailinglistarchive.com/html/android-developers@googlegroups.com/2009-06/msg00211.html – Mr. Sajid Shaikh Mar 30 '12 at 09:36
0

First up all you should add the marathi font (ttf) in devices. Below is the adb command for adding the font.

adb su push .ttf /system/fonts/DroidSansFallback.ttf

Then use this font for display.

ain
  • 22,394
  • 3
  • 54
  • 74
Anand M Joseph
  • 787
  • 7
  • 7