As I see you use some additional values to measure vertical and horizontal padding
val verticalSpaceAroundText = (textHeight * .12f + 6 + paddingVertical).toInt()
What is 6 and .12 here ?
Same for
val horizontalSpaceAroundText = ((textHeight * .24f) + 8 + paddingHorizontal).toInt()
What is 8 and .24 here ?