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

[TextParagraph/Button] Add support for line spacing. #98036

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Oct 9, 2024

Fixes godotengine/godot-proposals#10476

Related proposal godotengine/godot-proposals#9778 (adds support to TextParagraph but not to all controls using it).

@bruvzg bruvzg added this to the 4.x milestone Oct 9, 2024
@bruvzg bruvzg requested review from a team as code owners October 9, 2024 21:02
@timothyqiu
Copy link
Member

What's the unit of line spacing? Also, I think we should make it clear in the documentation whether "line spacing" here means:

  • The distance between adjacent baselines, or
  • The distance between the bottom of one line and the top of the next.

@bruvzg
Copy link
Member Author

bruvzg commented Oct 10, 2024

What's the unit of line spacing?

Pixel.

The distance between adjacent baselines, or
The distance between the bottom of one line and the top of the next.

It's additional spacing, not a total spacing, so in does not matter from what point it's measured.

It's used in the same way existing line_spacing in Label/Label3D/TextMesh and line_separation in RichTextLabel work, spacing is added to the line descent:

    pos.y += line_ascent;
    draw_line(pos, ...); // draw use baseline
    pos.y += line_descent + line_spacing; 

Edit: Added some extra info to the documentation for all of these.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Code looks good to me. It makes sense to expose this in Button since multiline buttons are fully supported in 4.x.

@KoBeWi KoBeWi modified the milestones: 4.x, 4.4 Nov 7, 2024
@Repiteo Repiteo merged commit 6bbc1cb into godotengine:master Nov 10, 2024
19 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 10, 2024

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.

7 participants