godotengine / godotengine/godot

Font Hinting (or positioning) seems slightly off.

Open
#90,779 8 comments 4 reactions 0 assignees View on GitHub
bug topic:gui
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

4.2.1 stable

### System information

Windows 10, Vulkan forward +, Nvidia 3070

### Issue description

When using a strongly hinted font, such as Tahoma, where the vertical lines should be pixel perfect, I've noticed that I can't seem to get pixel perfect hinted fonts in Godot.

Here are the import settings I'm using, which should be pixel perfect for a font at size 24:
![image](https://github.com/godotengine/godot/assets/7751182/92056465-8ba9-4a3d-a195-a35127afc06d)

If you zoom in, you can see the vertical lines are not pixel perfect:
![image](https://github.com/godotengine/godot/assets/7751182/43a79c62-87da-4e55-9a12-25e728df0f3f)

Though the horizontal lines do seem correct, which makes me wonder if the font is actually importing properly, but being positioned off pixel horizontally when displayed in the controls.

For comparison, this is how the font looks in the ttf viewer in Windows:
![image](https://github.com/godotengine/godot/assets/7751182/32351e0b-f2ef-4b28-91ee-553dbc9c0475)

And zoomed in:
![image](https://github.com/godotengine/godot/assets/7751182/5c903d61-c212-4dbf-8696-1a65e6b6aa30)

Notice everything is pixel perfect here for the vertical and horizontal lines with font size 24.

### Steps to reproduce

Use a font that has strong hinting, such as Tahoma.
In the import settings, set hinting to "Normal".
Might need to set subpixel positioning to "Disabled" (didn't seem to change anything, but I've heard it helps).
Use the font in a theme and set it to one of the sizes that hints well, like 24 or 12.

### Minimal reproduction project (MRP)

[test_font_hint(add own tahoma.ttf).zip](https://github.com/godotengine/godot/files/15005295/test_font_hint.add.own.tahoma.ttf.zip)

I've included a test project, but you will have to supply your own copy of tahoma.ttf, as I don't think it's legal to redistribute it. Should be on any copy of Windows, though. I couldn't find another font that had hinting this strong to use as an example.

Contributor guide

Open the contributing guide

Research direction

Start with the linked minimal reproduction project, supply a local Tahoma.ttf, and follow the listed import settings and font sizes. Compare the rendered vertical and horizontal strokes with the Windows TTF viewer; the issue is done when strongly hinted fonts render pixel-perfectly in the affected controls.

Written by the indexing model from the issue text.

Assessment

Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.