how to set includeFontPadding on canvas

Viewed 31

I am doing pixel-sensitive things so I must have zero font padding. I must do android:includeFontPadding="false" while drawing text on canvas. I examined Typeface, Paint, and Font classes but encountered nothing about font padding. How can I disable it? Thanks in advance.

Here is how I draw text.

val paint = Paint()

val plain: Typeface? = ResourcesCompat.getFont(mContext, R.font.default_font)

paint.typeface = Typeface.create(plain, Typeface.NORMAL)
paint.textSize = 35f
paint.textAlign = Paint.Align.CENTER

canvas.drawText("some text", 50f, 60f, paint)
0 Answers
Related