Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct the comment for resizeToFit #14363

Merged
merged 3 commits into from
Sep 27, 2023
Merged

Conversation

wy-luke
Copy link
Contributor

@wy-luke wy-luke commented Sep 27, 2023

According to the actual effect of resizeToFit(), I think it would be better to change the comment to to fit it's content rather to fit container.

The TextBlock will always be resized to fit it's content whether the text is too long or too large. Any excess beyond the container, like a plane attached the texture with one TextBlock, will not be displayed.

In the meanwhile, when I set the fontSize, width and resizeToFit simultaneously, it's width to fit fontSize, rather fontSize to fit width.

let text = new BABYLON.GUI.TextBlock();
text.text = "Hello world";
text.fontSize = 50;
text.width = 0.5
text.resizeToFit = true

It's all about the content. There's nothing about the container or to fit container.

As far as I'm concerned, the original version is kind of ambiguous to understand. And I think it might be better to make this modification for better clarity.

Thanks.

@wy-luke
Copy link
Contributor Author

wy-luke commented Sep 27, 2023

In Unity, there is a Best Fit option for text control. It makes the fontSize to fit the control size. In other words, you don't need to set the font size, it will be determined by the textBlock control size.

This is also one of the reason why I misunderstood the resizeToFit method in the beginning. And then, this comment made me even more confused.

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 27, 2023

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 27, 2023

@sebavan sebavan merged commit 3f4fc8f into BabylonJS:master Sep 27, 2023
10 checks passed
@wy-luke wy-luke deleted the patch-1 branch April 7, 2024 03:39
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.

None yet

3 participants