Skip to content

bugfix(gui): Scale fonts based on the smallest screen dimension so they scale independent of aspect ratio #1442

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Mauller
Copy link

@Mauller Mauller commented Aug 10, 2025

This PR adds the ability for the font scaling function to properly handle scaling fonts when non 4:3 aspect ratios are used.

At the moment since only the width is taken into account, fonts can be scaled larger than they should be when playing in a wide aspect ratio.

This PR makes sure that fonts scale with the smallest screen dimension so they scale in a more uniform way independent of the aspect ratio itself.

@Mauller Mauller self-assigned this Aug 10, 2025
@Mauller Mauller added Bug Something is not working right, typically is user facing GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Aug 10, 2025
@@ -187,7 +187,8 @@ void GlobalLanguage::parseFontFileName( INI *ini, void * instance, void *store,

Int GlobalLanguage::adjustFontSize(Int theFontSize)
{
Real adjustFactor = TheGlobalData->m_xResolution/800.0f;
// TheSuperHackers @bugfix Mauller 10/08/2025 Scale fonts based on the smallest screen dimension so they are independent of aspect ratio
Real adjustFactor = min(TheGlobalData->m_xResolution/800.0f, TheGlobalData->m_yResolution/600.0f);
Copy link

Choose a reason for hiding this comment

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

I expect that this will significantly shrink text size in the most popular resolution: 1920 x 1080

Originally the adjust factor was 2.4, with this change 1.8, which is a 25% size decrease (before m_resolutionFontSizeAdjustment).

How do we deal with that?

Copy link
Author

@Mauller Mauller Aug 10, 2025

Choose a reason for hiding this comment

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

The font was scaled larger than it should have been to begin with and only gets larger on a 21:9 monitor.

If you run this and compare, the fonts often look better and are more in proportion compared to before.

Copy link

@xezon xezon Aug 13, 2025

Choose a reason for hiding this comment

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

I took a look and texts look smaller than we are used to.

How about we make a follow up change and expose a ResolutionFontAdjustment setting to the Options.ini with a default value of 1.

This would then multiply with the ResolutionFontAdjustment from Language.ini and give the user the option to modify the default scaling without touching Language.ini

So in code it would then do

adjustFactor = 1.0f + (adjustFactor-1.0f) * m_resolutionFontSizeAdjustment * anotherResolutionFontSizeAdjustment;

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good, i can make the followup lead off this PR, will sort that in a sec.

@Mauller
Copy link
Author

Mauller commented Aug 10, 2025

This is 1920x1080 with the above fix
image
image

This is 1600x1200 which will scale as the game originally scaled the font
image
image

This is 1920x1080 without the tweaked scaling, the fonts are larger in proportion than they should be relative to 4:3 and the menu buttons etc.
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working right, typically is user facing Gen Relates to Generals GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants