机器人组自定义字体油漆 [英] android set custom font to a paint
本文介绍了机器人组自定义字体油漆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想绘制文本到油漆。如何使用自定义字体(前黑体)和大胆也借鉴呢?我想preffer使用系统字体,而不是从资产创建它。谢谢你。
I want to draw a text to a paint. How to draw it with a custom font (ex Helvetica ) and bold also? I would preffer to use a system font and not create it from assets. Thanks.
推荐答案
使用这样的:
Typeface plain = Typeface.createFromAsset(assetManager, pathToFont);
Typeface bold = Typeface.create(plain, Typeface.DEFAULT_BOLD)
Paint paint = new Paint();
paint.setTypeface(bold);
canvas.drawText("Sample text in bold Helvetica",0,0,paint);
这假定字体黑体
安装在设备上。如果自定义字体你的意思是没有安装的字体,那么你唯一的选择是提供其作为一种资产。
This assumes that the font Helvetica
is installed on the device. If by "custom font" you mean a font that is not installed, then your only option is to supply it as an asset.
这篇关于机器人组自定义字体油漆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文