How to get default font properties on Android?

I need to draw text on my canvas, and I would really avoid hard coding a certain size of text.

Is there a standard way to find the default text size (and other properties) used in the OS?

So far, I only found TextView.setTextAttributes (context, resId) to which I can pass R.android.attr.textAppearance.

But the fact is, I don’t want to create a TextView - I just have a Canvas, and I want to draw text using the default font.

Is it possible?:)

+3
source share
1 answer

Try using class Paint.FontMetricsand methods similar measureText()to Paint.

+4

Source: https://habr.com/ru/post/1731858/


All Articles