String str = "Hello";
int len = str.getBytes().length;
int w = len * 16;
int h = 32;
Bitmap strBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);
Canvas c = new Canvas(strBitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setTextSize(35);
Typeface tf = Typeface.createFromAsset(getAssets(), "caiyun");
paint.setTypeface(tf);
paint.setColor(0xFFFFFFFF);
paint.setTextAlign(Align.LEFT);
FontMetrics fm = paint.getFontMetrics();
c.drawText(str, 0, h + fm.top - fm.ascent, paint);
c.save();
String str = "Hello";
int len = str.getBytes().length;
int w = len * 16;
int h = 32;
Bitmap strBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);
Canvas c = new Canvas(strBitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setTextSize(35);
Typeface tf = Typeface.createFromAsset(getAssets(), "caiyun");
paint.setTypeface(tf);
paint.setColor(0xFFFFFFFF);
paint.setTextAlign(Align.LEFT);
FontMetrics fm = paint.getFontMetrics();
c.drawText(str, 0, h + fm.top - fm.ascent, paint);
c.save();
其中 c.drawText(str, 0, h + fm.top - fm.ascent, paint);