OpenTTD/OpenTTD

[Bug]: vehicle number and group name are a bit too close

SamuXarick opened this issue · 3 comments

Version of OpenTTD

openTTD 20240405-master-ga866166673

Expected result

insert a space between vehicle number and group name

Actual result

vehicle number and group name are a bit too close

Steps to reproduce

Captura de ecrã 2024-04-05 215739

This seems to only happen on large numbers as the UI was designed in small numbers in mind ?
For a small amount of ships it looks good:
image

What would be the desired approach to fix this ?

Apply more spacing to it ?
Lower the font so that it fits still on higher numbers ?

Does applying more space to it directly run the risk of messing the rest of the UI on spacing as well ?

I believe I've narrowed down a good place to start to line 1706 in vehicle_gui.cpp:

int text_offset = std::max<int>(profit.width, GetDigitWidth() * this->unitnumber_digits) + WidgetDimensions::scaled.hsep_normal;

It looks like GetDigitWidth takes the width of the standard font size, not the unit number font. So it gets closer as it gets longer and starts getting close to/overlapping the group name by 4 digits (It supports up to 5). Probably just need to be changed to GetDigitWidth() * 1.5 * this->unitnumber_digits or GetDigitWidth() * 2 * this->unitnumber_digits to have it offset without overlap.

Not available to test this at the moment, but that's about as simple as it gets is someone wants to give it a try.

The "unit number font" is the standard font, the issue is it's just counting digits, and ignoring the comma.