godotengine / godot

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

Font is rendered pixelated in editor due to font oversampling not being effective when zooming #33968

Closed letsgamedev closed 3 years ago

letsgamedev commented 4 years ago

Godot version: 3.2.beta2 and all before that :)

OS/device including version: Windows and MacOS

Issue description: Texts in the editor are rendered super pixelated but in-game normal. I am making a game with a resolution of 320*90. So I think, the font is rendered good if the zoom is set to 100% but is not rerendered if I zoom closer in. This makes the positioning of elements very time-consuming.

Steps to reproduce: Add a Label and zoom in.

The upper image is from editor, the lower from in-game.

rect837

Calinou commented 4 years ago

The DynamicFont oversampling factor is global, which means it can't be set on a per-font basis. We'd need this to be able to oversample the font when zooming in and out.

As a workaround, you can increase your project's base resolution. If you need to run it at a lower resolution for testing purposes, you can change Test Width and Test Height in the Project Settings.

girng commented 4 years ago

This makes the positioning of elements very time-consuming.

No it doesn't

akien-mga commented 4 years ago

@girng Please only comment if you have something constructive to say.

pwnorbitals commented 4 years ago

The DynamicFont oversampling factor is global, which means it can't be set on a per-font basis.

Is this still the case today ?

We'd need this to be able to oversample the font when zooming in and out.

Is this implemented / implementable ? I wouldn’t really know where to start

Calinou commented 4 years ago

Is this still the case today ?

Yes.

Is this implemented / implementable ? I wouldn’t really know where to start

This will require per-font oversampling factors to be implementable. Unfortunately, this is probably not trivial to add. Not to mention that re-rasterizing the font every time you zoom may negatively affect performance, especially at higher zoom levels.

Edit: With the upcoming addition of MSDF fonts, this issue may be solved as distance field fonts can be rendered at any scale without loss of quality: https://github.com/godotengine/godot/pull/44772

bruvzg commented 3 years ago

With the upcoming addition of MSDF fonts, this issue may be solved as distance field fonts can be rendered at any scale without loss of quality

And, as a side effect of MSDF implementation, oversampling can be overridden on the font basis as well.

Calinou commented 3 years ago

Note that this could argued to be done by design, since you generally want your text to always be readable at the base resolution. The fact that the font looks pixelated/blurry when zooming in could serve as an "alert" that your text won't be readable at the base resoluton.

If you want text to look crisper in the editor, it means you should probably be working with a higher base resolution. When working with a 320×90 base resolution, you should really be using a pixel art font if you want text to be readable at that resolution :slightly_smiling_face:

Either way, MSDF fonts will incidentally make fonts crisp regarldess of zoom or Control scaling in 4.0.

Calinou commented 3 years ago

MSDF fonts were implemented in https://github.com/godotengine/godot/pull/51908, closing.