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

RichTextLabel width changes on changing the window size when using the 2d stretch mode due to font oversampling #22580

Closed
Tracked by #39144
isaacremnant opened this issue Oct 1, 2018 · 6 comments

Comments

@isaacremnant
Copy link
Contributor

Godot version: 3.1 80d6bb7

Issue description: The width of a RichTextLabel's text relative to the window changes on resizing with the following conditions:

  1. The font is a DynamicFont
  2. Dynamic Font Oversampling is on
  3. The window stretch mode is 2D or Viewport

This does not happen with Labels! Default screen size on top, slightly resized window on the bottom. The first line is the Label, the second is the RichTextLabel:
image

The Label's width does change slightly, but it's much less egregious:
image

I would expect the RichTextLabel text to be the same as a Label and the value reported by font.get_string_size()...

Minimal reproduction project: FontTest.zip

@KoBeWi
Copy link
Member

KoBeWi commented Jun 25, 2020

Still valid in 3.2.2 rc4

On master the window viewport scaling doesn't seem to work, so it's not possible to test this properly.

@nihiluis
Copy link

looks especially bad with pixel fonts:

image

has anyone found a workaround? or just not use the RichTextLabel node?

@Calinou
Copy link
Member

Calinou commented Jun 28, 2021

This bug is likely due to RichTextLabel performing a different kind of rounding for font metrics compared to Label.

has anyone found a workaround? or just not use the RichTextLabel node?

You can set Extra Spacing > Char in the RichTextLabel's DynamicFont to 1 or 2. It should make fonts look closer to how they would look like when used in a Label.

@Calinou Calinou changed the title RichTextLabel width changes on changing the window size RichTextLabel width changes on changing the window size when using the 2d stretch mode due to font oversampling Sep 3, 2021
@bitbrain
Copy link
Contributor

This is also an issue for me.

@Listwon
Copy link
Contributor

Listwon commented Sep 17, 2021

This bug is likely due to RichTextLabel performing a different kind of rounding for font metrics compared to Label.

You were close, it was an issue with assigning float values to integer variables :) My PR fixes this issue, but I still have edge case where the last character from CJK font is not wrapped to the next line like in Label (so there is still some tiny difference in calculation).

rich_text_label_issue2

And before the fix (Labels on the left, RichTextLabels on the right)
rich_text_label_issue

Try switching to 1280x720 in this MRP:
render_text_bug.zip

@akien-mga akien-mga added this to the 3.4 milestone Sep 17, 2021
@akien-mga
Copy link
Member

Fixed by #52752.

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

7 participants