Open shadowfox87 opened 6 months ago
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.
The current fill alignment is actually forced justification. To support standard justification, we would need to expose 3 additional alignment options:
The alignment determines the last line's alignment only, with other lines using fill.
Ok so it's a confirmed bug. Thank you for looking into it. Would these alignment options be available in the next update?
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 https://github.com/godotengine/godot/pull/92565).
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.
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.
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.
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.
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.
Tested versions
System information
Windows 11 - Godot v4.3.beta.mono.custom_build [afbb108e3]
Issue description
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:
but fill gives me this
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: https://github.com/godotengine/godot/issues/74359 @cal
Steps to reproduce
To reproduce this:
Minimal reproduction project (MRP)
richtextlabelfill.zip