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

Label line spacing settings not working as expected in exported Windows binary due to additional newline being inserted #74351

Closed
FarbrorMartin opened this issue Mar 4, 2023 · 12 comments

Comments

@FarbrorMartin
Copy link

Godot version

4.0-stable

System information

Windows 10, Forward+, Intel HD 620

Issue description

In exported Windows binaries, the line spacing setting on the label font settings does not work properly. The line spacing is not like in the editor at all.
It seems like the setting is not applied at all in the exported binary.
In my example I used soft newlines to make multiple lines in the label.

This is the setting:
image

Editor:
image

Running from editor:
image

Exported game:
image

Steps to reproduce

Make a label with multiple lines of text. Set the line spacing to 0.
Compare the look of the label running in the editor and running an exported windows binary.

Minimal reproduction project

N/A

@Calinou
Copy link
Member

Calinou commented Mar 19, 2023

@FarbrorMartin Please upload a minimal reproduction project to make this easier to troubleshoot.

@conradhappeliv
Copy link
Contributor

conradhappeliv commented Mar 19, 2023

This has been happening to me since upgrading to Godot 4 as well. That being said, I just spent all morning trying to create a MRP and could not.

In my main project, I diff'd two Labels in a .tscn file (one affected by the bug, and one not) and couldn't find any meaningful difference between the two. Line endings (CRLF vs LF) seemed like a plausible suspect, but my .tscn file only had LFs.

However, in the process, I discovered that I can fix the issue by simply copying the label's text and pasting it back in (in the Godot editor). The wildest part is that git showed no diffs in the .tscn file when I did this, but it very clearly fixed the issue. And now that I've fixed it, I can't seem to bring the issue back...

As far as I can tell, this is ONLY caused by the Label's text content. Changing theme, font, line spacing, LabelSettings, etc had no effect whatsoever.

My suspicion is that this is caused by either:

  • git's/Godot's handling of line endings or
  • something in the .godot folder (I have these .gitignored, so I'm not sure how my "fix" affected those)

@FarbrorMartin
Copy link
Author

FarbrorMartin commented Mar 19, 2023

Note that I only experienced the problem in exported binaries (Win 64). In the editor it works as expected for me.
And the problem is not the newlines missing, it’s that the line spacing setting is not applied (in the exported binary).
I’ll try to upload an MRP tomorrow.

@conradhappeliv
Copy link
Contributor

conradhappeliv commented Mar 19, 2023

This was happening to me even if I don't set line_spacing (or label_settings) at all, so I think the issue is something different than that setting not being applied. It was happening on Labels with everything (except the actual text) set to defaults, which is why I think that it's related to the text content itself (and also, copy-pasting the text content is what fixed it for me).

@Rindbee
Copy link
Contributor

Rindbee commented Apr 24, 2023

Probably related to autowrap_mode not being AUTOWRAP_OFF, see #74052.

@Calinou Calinou changed the title Label line spacing settings not working as expected in exported Windows binary Label line spacing settings not working as expected in exported Windows binary due to additional newline being inserted May 4, 2023
@nezvers
Copy link

nezvers commented May 24, 2023

I hoped to workaround with custom drawing a multi-line string, Same problem.
CustomLabel.gd.zip

@harper-rhett
Copy link

harper-rhett commented May 30, 2023

Probably related to autowrap_mode not being AUTOWRAP_OFF, see #74052.

I also had this problem, and changing the autowrap mode to off had no effect. @conradhappeliv's solution of cutting and pasting the text back in, on the contrary, seemed to work great.

@EntroPiGames
Copy link

I recently also ran into this issue when setting the text of a label from a C# script.

I was using the System.Environment.NewLine string instead of "\n" and the line spacing was different in the exported project.

I created a small test project to show the difference.
The left label is using "\n", the right label is using System.Environment.NewLine.

Project run from editor in Windows:

image

Exported Windows project:

image

On Windows System.Environment.NewLine is a string containing \r\n while on other platforms it is \n, so maybe that is why it only seems to affect projects exported for Windows?
Regardless, it's weird that there's a difference between the editor and exported projects in Windows.

@Calinou I've added a minimal reproduction project: NewLine.zip

It uses the C# build of 4.0.3.

@Calinou
Copy link
Member

Calinou commented Jun 2, 2023

Does this issue disappear if you disable Editor > Export > Convert Text Resources to Binary in the Project Settings before exporting?

@EntroPiGames
Copy link

Does this issue disappear if you disable Editor > Export > Convert Text Resources to Binary in the Project Settings before exporting?

No, disabling that option has no effect.

Here's a screenshot of the exported project with the setting disabled:
image

@Calinou
Copy link
Member

Calinou commented Jul 16, 2023

Consolidating in #71276. Thanks for the report!

@VincentPoteet
Copy link

I know I'm late to the party, but I just wanted to share how I dealt with the issue.
I just put this in a _ready() function or something:

text= text.c_escape()
text = text.replace("\\r\\n", "\n")
text = text.c_unescape()

Hope this happens to help someone!

-a gamer

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

8 participants