korlibs / korlibs/korge

Changing scale changes getBounds() in Text with autoScaling = true

Open
#325 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
3k
Forks
148
Avg merge
13h 44m
Merged PRs (30d)
1

Description

The same is not true of other views, e.g. SolidRect

Barebones repro:
```
class TestScene : Scene() {
override suspend fun Container.sceneInit() {
val left = 200
val right = 700

val redBox = solidRect(100, 100, Colors.RED) {
xy(500, 500)
}
val text = text("This is a Message") {
xy(left, 200)
fontSize = 32.0
}
println("redBox")
println("bounds = ${redBox.getBounds()}")
redBox.scale = 0.2
println("==0.2==")
println("bounds = ${redBox.getBounds()}")
redBox.scale = 2.0
println("==2.0==")
println("bounds = ${redBox.getBounds()}")
redBox.scale = 1.0
println("==1.0==")
println("bounds = ${redBox.getBounds()}")
println("=default==")
println("bounds = ${text.getBounds()}")
text.scale = 0.2
println("==0.2==")
println("bounds = ${text.getBounds()}")
text.scale = 2.0
println("==2.0==")
println("bounds = ${text.getBounds()}")
text.scale = 1.0
println("==1.0==")
println("bounds = ${text.getBounds()}")
}
```

Output:
```
redBox
bounds = Rectangle(x=0, y=0, width=100, height=100)
==0.2==
bounds = Rectangle(x=0, y=0, width=100, height=100)
==2.0==
bounds = Rectangle(x=0, y=0, width=100, height=100)
==1.0==
bounds = Rectangle(x=0, y=0, width=100, height=100)
=default==
bounds = Rectangle(x=0.7486979166666667, y=0, width=233.7391304347826, height=31.304347826086957)
==0.2==
bounds = Rectangle(x=0.14973958333333334, y=0, width=250.43478260869566, height=41.73913043478261)
==2.0==
bounds = Rectangle(x=1.4973958333333335, y=0, width=231.65217391304347, height=29.217391304347824)
==1.0==
bounds = Rectangle(x=0.7486979166666667, y=0, width=233.7391304347826, height=31.304347826086957)
```

See also: https://kotlinlang.slack.com/archives/CJEF0LB6Y/p1610396895392300

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the barebones TestScene reproduction and comparing Text with SolidRect, whose getBounds() output remains unchanged when scaled. Then trace the Text autoScaling and getBounds() implementation; done means Text bounds behave consistently when scale changes, with regression coverage for the reported outputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.