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

Fix #10150: Force FS_SMALL for small viewport signs. #10283

Merged
merged 2 commits into from Dec 25, 2022

Conversation

PeterN
Copy link
Member

@PeterN PeterN commented Dec 25, 2022

Motivation / Problem

As per #10150, small town sign labels may be cropped with Truetype fonts.

image

This is a workaround for string widths being different with mixed font-sizes.

For some reason (with Uniscribe at least), the string bounding box of "{FS_SMALL}Text" can be different when called starting with FS_SMALL and FS_NORMAL.

Description

image

This is resolved by explicitly drawing small signs with FS_SMALL, although the underlying problem is not touched.

Limitations

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

This is a workaround for string widths being different with mixed
font-sizes.
(This method of drawing shadows is hilarious and needs replacing, but
this is a quick fix.)
@@ -1323,7 +1323,7 @@ void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const Vie
int shadow_offset = 0;
if (string_small_shadow != STR_NULL) {
shadow_offset = 4;
AddStringToDraw(sign->center - sign_half_width + shadow_offset, sign->top, string_small_shadow, params_1, params_2, INVALID_COLOUR, sign->width_small);
AddStringToDraw(sign->center - sign_half_width + shadow_offset, sign->top, string_small_shadow, params_1, params_2, INVALID_COLOUR, sign->width_small | 0x8000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there not a flag enum for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is only used here, and only tested with HasBit(ss.width, 15). I have in mind a proper rewrite so don't really want to start adding flags.

@PeterN PeterN merged commit c8cc61d into OpenTTD:master Dec 25, 2022
@PeterN PeterN deleted the fix-10150 branch December 25, 2022 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants