android set custom font to a paint

后端 未结 5 2292
难免孤独
难免孤独 2020-11-30 23:16

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 fr

5条回答
  •  自闭症患者
    2020-11-30 23:48

    If you want to use a font from resources (Kotlin):

    val textPaint = TextPaint()
    textPaint.typeface = resources.getFont(R.font.font_name)
    

    This might not be related to the question, but this is what I was looking for - maybe somebody would need it too.

提交回复
热议问题