public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MyView vw = new MyView(this); setContentView(vw); mFont = Typeface.createFromAsset(getAssets(), "balloons.ttf"); }
public void onDraw(Canvas canvas) { canvas.drawColor(Color.LTGRAY); Paint Pnt = new Paint(); int y = 1; Pnt.setAntiAlias(true); Pnt.setTextSize(30); Pnt.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); canvas.drawText("Font:Default", 10, y++ * 40, Pnt); Pnt.setTypeface(Typeface.create(Typeface.DEFAULT_BOLD, Typeface.NORMAL)); canvas.drawText("Font:Default Bold", 10, y++ * 40, Pnt); Pnt.setTypeface(Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL)); canvas.drawText("Font:Monospace", 10, y++ * 40, Pnt); Pnt.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL)); canvas.drawText("Font:Sans Serif", 10, y++ * 40, Pnt); Pnt.setTypeface(Typeface.create(Typeface.SERIF, Typeface.NORMAL)); canvas.drawText("Font:Serif", 10, y++ * 40, Pnt); }
public final Typeface getTypeFaceFromAsset(String assetName) { try { return Typeface.createFromAsset(this.getResources().getAssets(), assetName); } catch (Throwable e) { } return null; }
public final Typeface getTypeFaceFromByteArray(byte[] data) { try { File f = getDataCacheFile(data); if (f != null) return Typeface.createFromFile(f); } catch (Exception e) { Log.e("JUCE", e.toString()); } return null; }