机器人组自定义字体油漆自定义、机器人、油漆、字体

由网友(暂停白昼)分享简介:我想绘制文本到油漆。如何使用自定义字体(前黑体)和大胆也借鉴呢?我想preffer使用系统字体,而不是从资产创建它。谢谢你。I want to draw a text to a paint. How to draw it with a custom font (ex Helvetica ) and bold also...

我想绘制文本到油漆。如何使用自定义字体(前黑体)和大胆也借鉴呢?我想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.

阅读全文

相关推荐

最新文章