Skiko Version : 0.8.6 Hey everyone, I am working w...
# multiplatform
s
Skiko Version : 0.8.6 Hey everyone, I am working with Skiko Multiplatform Library in both Web (WASM/JS) and JVM, and I’ve encountered a discrepancy in how the width of the text "Lorem" is measured in both environments. Web (WASM/JS) Code:
Copy code
val font = loadFontFromUrl("Roboto/Roboto-Regular.ttf")
font.size = 12 * 1.33f
println("Width : ${font.measureTextWidth("Lorem")}")
Width printed in Web (JS): 42.0 JVM Code:
Copy code
val typeface = Typeface.makeFromFile("kotlin/Roboto-Regular.ttf")
var font = Font()
font.setTypeface(typeface)
font.size = 12 * 1.33f
println("Width : ${font.measureTextWidth("Lorem")}")
Width printed in JVM: 45.53432 Problem: • The width of the same text
"Lorem"
is calculated differently between Web and JVM. • In Web, the width is
42.0
, while in JVM, it’s
45.53432
. I’m using the same font ("Roboto-Regular.ttf") and setting the same size (
12 * 1.33f
), so I don't understand why the widths are different. Here, 1.33f used for ( pt to px conversion ). Has anyone experienced something like this or can explain what might be causing this discrepancy?