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

Incorrect font rendering despite disabling Subpixel Positioning #74694

Closed
20milliliter opened this issue Mar 9, 2023 · 13 comments · Fixed by godotengine/godot-docs#7355
Closed

Comments

@20milliliter
Copy link

Godot version

4.0.stable

System information

Windows 10, Forward+, NVIDIA Studio 527.56

Issue description

A pixel font is being rendered incorrectly despite disabling Subpixel Positioning. (#70327)

image
*image is exact size

Steps to reproduce

The minimal reproduction project shows various sizes of the font, comparing their appearance in engine and how they are supposed to look (via a keep size texture rect containing an image created seperately).

The left column shows the text in engine, the right shows the texture rects.
The font sizes from top to bottom are 12, 16, 24, 32, and 36.

Minimal reproduction project

Bug.zip

@xahon
Copy link

xahon commented Mar 20, 2023

I have an issue with font rendering as well.
On the left is rendered text in Godot (10px size) and on the right default Windows 10 font viewer
image

I've tried different import options. I use these options now because it looks the best of all other setting sets
image

The UI control and all it's parents are not scaled (1, 1, 1)


Here is an SDF approach. On the left is how it looks like in the editor, on the right how it looks in the game

image

I've tried different MSDF settings, it still looks awful

It worth noting that I use fixed viewport size and window override. Both have the same aspect ratio.

@thornySoap
Copy link

This is only when alignment is center (isn't it), so probably a devide-by-2 thing

@Calinou
Copy link
Member

Calinou commented May 15, 2023

This is not a bug; this occurs because you're displaying the font at a non-integer multiple. Pixel art fonts must be displayed at a multiple of the size they were designed for to look correct. If you follow this guidance correctly (including on the scale of Control nodes that display the font), you shouldn't even need to disable antialiasing on import – disabling subpixel positioning is enough.

For example, if I enable antialiasing, notice how all fonts turn blurry except the ones that are a multiple of the intended size (16 and 32):

image

Unifont is designed for size 16.

@thornySoap
Copy link

thornySoap commented May 15, 2023

But then how to explain this?:

Screenshot 2023-05-15 17:28:07

Screenshot 2023-05-15 17:28:07

viewport width 200 width 199

@Calinou
Copy link
Member

Calinou commented May 15, 2023

@thornySoap If using the canvas_items or viewport stretch mode, this is likely an issue with the window size not being an integer multiple, which causes uneven pixel scaling. See godotengine/godot-proposals#1666.

@thornySoap
Copy link

thornySoap commented May 15, 2023

@Calinou this is with stretch mode disabled:

Screenshot 2023-05-15 17:28:07

test.zip

@Calinou
Copy link
Member

Calinou commented May 15, 2023

@thornySoap You have subpixel positioning set to Auto on fonts/Pixeloid/PixeloidSans.ttf in the Import dock. Set it to Disabled, click Reimport then use Scene > Reload Saved Scene. Doing so fixes the font display for me in the MRP you uploaded.

@thornySoap
Copy link

@Calinou thank you yery much. Sorry for having annoyed you with that 😣

@20milliliter
Copy link
Author

Unifont is designed for size 16.

@Calinou How do you know?
Why does other software disagree with you?

image
image

@Calinou
Copy link
Member

Calinou commented May 16, 2023

12 pt is different from 16px :)

Different software uses different coventions for font sizes, so it's best to try different font sizes until you find one that looks "right".

@20milliliter
Copy link
Author

Different software uses different coventions for font sizes

TIL. Very unintuitive.
@Calinou Mention of this should also be included in your PR, I feel.

@Calinou
Copy link
Member

Calinou commented May 20, 2023

@Calinou Mention of this should also be included in your PR, I feel.

Done: godotengine/godot-docs#7389

@20milliliter
Copy link
Author

Great, thanks so much.

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

Successfully merging a pull request may close this issue.

6 participants