godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.89k stars 21.04k forks source link

Unable to Put Multiple NewLines After Applying FontFile to RichTextLabel #77936

Open jaberwok2010 opened 1 year ago

jaberwok2010 commented 1 year ago

Godot version

v4.0.3.stable.official [5222a99f5]

System information

Linux Mint 20.3 (una)

Issue description

Having a FontFile loaded into the Theme Overrides for a Label or RichTextLabel causes the node in question to condense repeated newlines tags down to a single newline. In other words, "\n\n\n\n" becomes "\n". This only occurs when a FontFile is loaded, and does not depend upon whether an actual font is loaded, present, or referenced. I would expect that loading a FontFile would not affect the way that Labels of any kind apply and render newlines.

Steps to reproduce

  1. Open a Label or RichTextLabel. (If it is a RichTextLabel, check the node Inspector to make sure that the BBCode_Enabled box is checked.)
  2. Insert text into the Text Box that includes several newlines in a row. Example Text:
    
    This example text precedes three newlines.

This is example text both follows and precedes three newlines.

This is example text both follows three newlines.


3. Open the "Fonts" drop down, under the "Theme Overrides" drop down in the Control section of the Inspector.
4. Next to "Normal Font", click the down arrow and choose "New FontFile"
5. Go back to the Text Box, and modify the text slightly -- for example, by pressing 'enter' and then 'backspace'.
6. Uncheck the box next to "Normal Font", then repeat step 5.

### Minimal reproduction project

[FontIssue.zip](https://github.com/godotengine/godot/files/11671620/FontIssue.zip)
Calinou commented 1 year ago

It looks like this issue disappears when you set a valid font then edit the text in any way:

image

An empty FontFile is not valid.

jaberwok2010 commented 1 year ago

I have this issue regardless of whether a font resource is set within the FontFile or not. In fact, I became aware of this issue in part because I could not figure out why Labels/RichTextLabels from 3.X no longer worked as I expected after conversion to 4.0 -- and trying to replace them with new Labels/RichTextLabels resulted in the same unexpected behavior.

Has there been a change in what constitutes a valid font from 3.X to 4.0?

Edit: Evidently I had been loading .tres files produced in 3.X instead of the original font file. I am not sure why that did not work, but shifting to loading the original font file has corrected the issue. I am still unclear as to why an invalid FontFile would result in this particular manifestation, but in any case the issue I had appears to be corrected with this change. Thank you very much for your help.

scripturial commented 11 months ago

Just adding a "me too" on this one. The spacing in between paragraphs was not appearing at a ll.

For me, the solution was to reset all of the font settings fields in rich text labels, and also inside my theme file. Now I have re-added the font settings, and line spacing now behaves as normal.

If the problem is that something is not loading properly, perhaps a better error message needs to logged out somewhere when something odd is picked up? I don't know if it is related to this problem, but I do see an error in my console about a bad file, but the error message provides no clue as to where to look to find out what might be the cause of the problem. Here is a screenshot to clarify: