0

I can set font Typeface with java script but is it a way to set custom fonts without programming in widget properties panel or design text mode or something else?

1 Answers1

0

Your question has been answered here How to use a custom typeface in a widget?

This is an example.

public Bitmap buildUpdate(String time) 
{
Bitmap myBitmap = Bitmap.createBitmap(160, 84, Bitmap.Config.ARGB_4444);
Canvas myCanvas = new Canvas(myBitmap);
Paint paint = new Paint();
Typeface clock = Typeface.createFromAsset(this.getAssets(),"Clockopia.ttf");
paint.setAntiAlias(true);
paint.setSubpixelText(true);
paint.setTypeface(clock);
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
paint.setTextSize(65);
paint.setTextAlign(Align.CENTER);
myCanvas.drawText(time, 80, 60, paint);
return myBitmap;
}

That's the part doing the font to image thing, and this is how to use it:

String time = (String) DateFormat.format(mTimeFormat, mCalendar);
RemoteViews views = new RemoteViews(getPackageName(), R.layout.main);
views.setImageViewBitmap(R.id.TimeView, buildUpdate(time));

You can adjust it to your needs

Community
  • 1
  • 1
Kennedy
  • 547
  • 4
  • 23