Is it possible to read a TextAppearance attribute programmatically?
I have this TextAppearance style:
<style name="TextAppearance.DesignSystem.Payback.Headline3" parent="@style/TextAppearance.MaterialComponents.Headline3">
    <item name="android:fontFamily">@font/payback</item>
    <item name="android:letterSpacing">0.0</item>
    <item name="android:textColor">?android:attr/textColorPrimary</item>
    <item name="android:textSize">40sp</item>
    <item name="android:textStyle">normal</item>
    <item name="fontFamily">@font/payback</item>
</style>
And I would like to read the android:textSize programmatically.
I managed to get it like this:
private val textAppearanceTextView by lazy { TextView(context) }
fun getTextAppearanceTextSize(@StyleRes textAppearance: Int): Int {
    textAppearanceTextView.apply {
        setTextAppearance(textAppearance)
        return textSize.roundToInt()
    }
}
but this is pretty ugly.
Is there a cleaner way to read an attribute of a TextAppearance?
 
    