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

RichText Justified Behavior is Not Correct #92561

Open
shadowfox87 opened this issue May 30, 2024 · 9 comments
Open

RichText Justified Behavior is Not Correct #92561

shadowfox87 opened this issue May 30, 2024 · 9 comments

Comments

@shadowfox87
Copy link

Tested versions

  • Reproduceable in Godot v4.3.beta.mono.custom_build [afbb108e3]

System information

Windows 11 - Godot v4.3.beta.mono.custom_build [afbb108e3]

Issue description

  • Godot version v4.3.beta.mono.custom_build [afbb108e3]

I've tried using the [fill] but it does not behave like the word justify, for example, on lines where theres little text and then a line break, it does extend them up until the box width, making it have super large empty spaces, instead of simply treating that as normal left align (i feel its lacking a thing like, if space width on line exceeds x value then treat this line as left align instead of [fill]).

Basically, what i would like is this:
image

but fill gives me this
image

It should detect the line break, and justify the text on the space from beginning up to where the line were broken, not up until to the end of the actual line past the line break.

Someone opened a similar issue but it didn't really fix the issue: #74359
@cal

Steps to reproduce

To reproduce this:
image

Minimal reproduction project (MRP)

richtextlabelfill.zip

@HKunogi
Copy link
Contributor

HKunogi commented May 30, 2024

I suffer from this exact problem, the fill tag does not reproduce what is seem on word software justify, if it should, then its definitely not doing so, and if its a totally different meaning tag, then the richtextlabel is lacking an justify option.

@Calinou
Copy link
Member

Calinou commented May 30, 2024

The current fill alignment is actually forced justification. To support standard justification, we would need to expose 3 additional alignment options:

  • Fill Left
  • Fill Center
  • Fill Right

The alignment determines the last line's alignment only, with other lines using fill.

@shadowfox87
Copy link
Author

Ok so it's a confirmed bug. Thank you for looking into it. Would these alignment options be available in the next update?

@bruvzg
Copy link
Member

bruvzg commented May 30, 2024

Default justification options include JUSTIFICATION_DO_NOT_SKIP_SINGLE_LINE flag which forces first line justification, you are supposed to be able to override it by using [p justification_flags=word,kashida,skip_last align=fill] instead of [fill], but there's a bug and default flags aren't cleared (fix #92565).

@bruvzg
Copy link
Member

bruvzg commented May 30, 2024

To support standard justification, we would need to expose 3 additional alignment options:

Fill Left
Fill Center
Fill Right

The alignment determines the last line's alignment only, with other lines using fill.

Might be also useful to add a configurable threshold to skip justification for any line that is too short.

@Calinou
Copy link
Member

Calinou commented May 30, 2024

Default justification options include JUSTIFICATION_DO_NOT_SKIP_SINGLE_LINE flag which forces first line justification, you are supposed to be able to override it by using [p justification_flags=word,kashida,skip_last align=fill] instead of [fill], but there's a bug and default flags aren't cleared (fix #92565).

For RichTextLabel in particular, I wonder if the skip_last parameter should be used by default in the [fill] tag, with [fill align=left|center|right] being added and [fill force=true] for forced justification on the last line (i.e. no skip_last).

This would incur a small visual breakage in existing projects that use [fill], but I don't think the current behavior is being relied upon a lot. Most of the time, people expect the last line not to use justification by default.

@HKunogi
Copy link
Contributor

HKunogi commented Oct 6, 2024

I believe on top of having the option skip_last, would be useful to have an option skip_intentional_breaks, as in, skip lines that breaks to a new line by the input string (the input contains \n or such), so if one have a string that contains multiple lines, the lines that don't fit on a single line and get auto wrapped would be justified, while the lines with actual line breaks would be ignored.

@bruvzg
Copy link
Member

bruvzg commented Oct 6, 2024

I believe on top of having the option skip_last, would be useful to have an option skip_intentional_breaks, as in, skip lines that breaks to a new line by the input string (the input contains \n or such)

This should be covered by skip_last, since \n will start a new paragraph which is processed independently.

@HKunogi
Copy link
Contributor

HKunogi commented Oct 6, 2024

I believe on top of having the option skip_last, would be useful to have an option skip_intentional_breaks, as in, skip lines that breaks to a new line by the input string (the input contains \n or such)

This should be covered by skip_last, since \n will start a new paragraph which is processed independently.

Sorry, after some testing, indeed its covered, the issue I were having is if I use StringBuilder in C# to build an string with multiple lines, and it is running on windows, then Environment.NewLine is CRLF while on UNIX would be just LF, the issue I faced was that, godot actually treated both the CR and LF as one line each, so it were truly jumping 2 lines instead of 1, i changed it to force only the LF and it sorted this issue, but would be cool if there could be an option to handle that accordingly, or maybe godot should just skip/ignore CR.

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

No branches or pull requests

4 participants