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

[Button] Fix theme elements size rounding errors not keeping sufficient space for the text. #90838

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Apr 18, 2024

Fixes #90745

@bruvzg bruvzg added this to the 4.3 milestone Apr 18, 2024
@bruvzg bruvzg requested a review from a team as a code owner April 18, 2024 08:50
@@ -358,7 +358,7 @@ void Button::_notification(int p_what) {
if (!xl_text.is_empty()) {
text_buf->set_alignment(align_rtl_checked);

float text_buf_width = MAX(1.0f, drawable_size_remained.width); // The space's width filled by the text_buf.
float text_buf_width = Math::ceil(MAX(1.0f, drawable_size_remained.width)); // The space's width filled by the text_buf.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be round() to avoid errors on the other end where 62.000000047 would become 63?
Or is it better to err on the side of caution and have one too many pixels instead of one too few?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An extra pixel in the text buffer should not be an issue (it's setting max. width available for the string), so always ceiling is probably safer (I'm not sure how big the error can get since a lot of code is involved in control size calculations).

@akien-mga akien-mga merged commit a202027 into godotengine:master Apr 18, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text clipping on buttons when using a custom display scale
2 participants