Graphics>Typefaces
这里讲解从本地加载一个字体文件,绘制text。
public SampleView(Context context) {
super(context);
mFace = Typeface.createFromAsset(getContext().getAssets(),
"fonts/samplefont.ttf");
mPaint.setTextSize(64);
}
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
mPaint.setTypeface(null);
canvas.drawText("Default", 10, 100, mPaint);
mPaint.setTypeface(mFace);
canvas.drawText("Custom", 10, 200, mPaint);
}可以看到一个字体文件samplefont.ttf放在assets文件夹下;
通过typeface.createFromAsset加载;
设置到画笔上,进行绘制。
 (GraphicsTypefaces)&spm=1001.2101.3001.5002&articleId=78060228&d=1&t=3&u=3fa26a4a5d334ab1a861973a1fa8ccd0)
973

被折叠的 条评论
为什么被折叠?



