Skip to content

Commit e41707c

Browse files
committed
bugfix(gui): Scale fonts based on the smallest screen dimension so they scale independent of aspect ratio
1 parent cfb0667 commit e41707c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Generals/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,11 @@ void GlobalLanguage::parseFontFileName( INI *ini, void * instance, void *store,
187187

188188
Int GlobalLanguage::adjustFontSize(Int theFontSize)
189189
{
190-
Real adjustFactor = TheGlobalData->m_xResolution / (Real)DEFAULT_DISPLAY_WIDTH;
191-
adjustFactor = 1.0f + (adjustFactor-1.0f) * m_resolutionFontSizeAdjustment;
190+
// TheSuperHackers @bugfix Mauller 25/08/2025 Scale fonts based on the smallest screen dimension so they are independent of aspect ratio
191+
// We also rescale the font size adjustment to make the ingame fonts closer to what players have been used with the original scaling
192+
Real adjustFactor = min(TheGlobalData->m_xResolution / (Real)DEFAULT_DISPLAY_WIDTH, TheGlobalData->m_yResolution/ (Real)DEFAULT_WORLD_HEIGHT );
193+
adjustFactor = 1.0f + (adjustFactor-1.0f) * ( 0.25f + m_resolutionFontSizeAdjustment );
192194
if (adjustFactor<1.0f) adjustFactor = 1.0f;
193-
if (adjustFactor>2.0f) adjustFactor = 2.0f;
194195
Int pointSize = REAL_TO_INT_FLOOR(theFontSize*adjustFactor);
195196
return pointSize;
196197
}

GeneralsMD/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,11 @@ void GlobalLanguage::parseFontFileName( INI *ini, void * instance, void *store,
191191

192192
Int GlobalLanguage::adjustFontSize(Int theFontSize)
193193
{
194-
Real adjustFactor = TheGlobalData->m_xResolution / (Real)DEFAULT_DISPLAY_WIDTH;
195-
adjustFactor = 1.0f + (adjustFactor-1.0f) * m_resolutionFontSizeAdjustment;
194+
// TheSuperHackers @bugfix Mauller 25/08/2025 Scale fonts based on the smallest screen dimension so they are independent of aspect ratio
195+
// We also rescale the font size adjustment to make the ingame fonts closer to what players have been used with the original scaling
196+
Real adjustFactor = min(TheGlobalData->m_xResolution / (Real)DEFAULT_DISPLAY_WIDTH, TheGlobalData->m_yResolution/ (Real)DEFAULT_WORLD_HEIGHT );
197+
adjustFactor = 1.0f + (adjustFactor-1.0f) * ( 0.25f + m_resolutionFontSizeAdjustment );
196198
if (adjustFactor<1.0f) adjustFactor = 1.0f;
197-
if (adjustFactor>2.0f) adjustFactor = 2.0f;
198199
Int pointSize = REAL_TO_INT_FLOOR(theFontSize*adjustFactor);
199200
return pointSize;
200201
}

0 commit comments

Comments
 (0)