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

Button font is rendered incorrectly when using pixel art TTF font #70327

Closed
boruok opened this issue Dec 20, 2022 · 5 comments · Fixed by godotengine/godot-docs#6748
Closed

Comments

@boruok
Copy link
Contributor

boruok commented Dec 20, 2022

Godot version

v4.0.beta.custom_build [dcb3754]

System information

Ubuntu 22.10, GTX1060, Vulkan

Issue description

tried to use pixel-art .ttf font on my project. Looks like Button font renders incorrectly compared to other buttons (checkbutton, link...)

below is how it looks, from top to bottom Button, CheckButton, LinkButton, MenuButton. All have same font with same size. Only Button glitched

Screenshot from 2022-12-20 11-27-46

Steps to reproduce

  1. open attachment
  2. try to change button text

Minimal reproduction project

New Game Project.zip

@boruok boruok changed the title Button font Button font glitch Dec 20, 2022
@Calinou Calinou changed the title Button font glitch Button font is rendered incorrectly when using pixel art TTF font Dec 29, 2022
@Calinou
Copy link
Member

Calinou commented Dec 29, 2022

I can confirm this on v4.0.beta.custom_build [b6e0603] (Linux).

image

The issue doesn't occur if font size is decreased from 7 to 6 on the Button:

image

On the other hand, the other 3 nodes are using a font size of 7, not 6. The "u" also looks different on the Button compared to the other nodes.

There seems to be a off-by-one error in general: Button needs a font size that is 1 pixel smaller to look similar to other nodes' font sizes. Here's an example with Button's font size set to 13, and CheckButton/LinkButton/MenuButton set to 14:

image

All screenshots above were taken with a zoom of 200% (integer scaling) to avoid any artifacts.

cc @bruvzg

@Calinou Calinou added this to the 4.0 milestone Dec 29, 2022
@bruvzg
Copy link
Member

bruvzg commented Dec 29, 2022

Button style box or/and text alignment is likely resulting in a non integer horizontal offset, which is in general fine.

Disable subpixel positioning in the font import settings and reimport the font, it's not suitable for pixel art fonts (but can improve rendering of the small sizes of the usual vector fonts).

@bruvzg
Copy link
Member

bruvzg commented Dec 29, 2022

Since the particular font in the MRP is a vector font, but with all vertices aligned to the pixel grid and only line segments, it's not possible to detect if it's a pixel art font automatically. But we probably should auto disable subpixel positioning for true fixed size bitmap TTFs.

@boruok
Copy link
Contributor Author

boruok commented Dec 30, 2022

@bruvzg thanks! solved.

@boruok boruok closed this as completed Dec 30, 2022
@Calinou Calinou added documentation and removed bug labels Dec 30, 2022
@Calinou
Copy link
Member

Calinou commented Dec 30, 2022

Reopening, as this needs to be documented on Using fonts.

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.

3 participants