in platf-android/src/androidMain/kotlin/org/jetbrains/letsPlot/android/canvas/AndroidContext2d.kt [167:183]
override fun measureText(str: String): TextMetrics {
val width = fillPaint.measureText(str, 0, str.length) // logical width. Always > 0 for a non-empty string.
val visualBounds = Rect()
fillPaint.getTextBounds(str, 0, str.length, visualBounds) // pixel bounds. Can be empty (e.g., for space character)
val textMetrics = TextMetrics(
ascent = visualBounds.top.toDouble(),
descent = visualBounds.bottom.toDouble(),
bbox = DoubleRectangle.XYWH(
x = visualBounds.left,
y = visualBounds.top,
width = width,
height = visualBounds.height()
),
)
return textMetrics
}