Skip to content

fix: Apply the scale of a ScrollTextBoxComponent only once - #4281

Merged
spydon merged 1 commit into
flame-engine:mainfrom
Yasser-Ameur:fix/scroll-text-box-scale
Dec 1, 2026
Merged

spydon merged 1 commit into
flame-engine:mainfrom
Yasser-Ameur:fix/scroll-text-box-scale

Conversation

@Yasser-Ameur

Copy link
Copy Markdown
Contributor

Description

A ScrollTextBoxComponent applies its scale twice. The constructor passes scale to the component itself and again to the ClipComponent it creates as its child, so the two multiply: with scale: Vector2.all(2) the text is drawn at 4x, and the clip area is four times the box instead of twice.

final component = ScrollTextBoxComponent(
  size: Vector2(200, 100),
  text: 'Short text',
  scale: Vector2.all(2),
);
// absoluteScale of the inner text box: [4.0, 4.0] on main, [2.0, 2.0] with this change

The scale argument is no longer passed to the inner clip, so it is applied once, by the component. Nothing changes at the default scale of 1. scale is the only constructor argument that was applied twice. The line has been there since the component was added in #2901.

The new test in scroll_text_box_component_test.dart checks the absolute scale of the inner text box; it fails on main with [4.0, 4.0].

Locally on Windows, from packages/flame: dart format --output=none --set-exit-if-changed on the two changed files reports 0 changed, flutter analyze reports no issues, and scroll_text_box_component_test.dart gives 6 passed. The melos gates, cspell and the markdown check were not run.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • [-] I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • [-] I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

ScrollTextBoxComponent passed its scale to super and also to the inner
ClipComponent, so the text and its clip area were scaled twice: a scale
of 2 rendered the text at 4 times its size. The clip now keeps a unit
scale and inherits the scale from its parent.
@Yasser-Ameur
Yasser-Ameur marked this pull request as ready for review December 1, 2026 07:17
@spydon
spydon added this pull request to the merge queue Dec 1, 2026
Merged via the queue into flame-engine:main with commit b95a6c1 Dec 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants