Skip to content

Commit 4c50112

Browse files
committed
tweak(font): Redesign and fix the font scaling for large resolutions and non 4:3 aspect ratios
1 parent c9e730d commit 4c50112

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "Common/FileSystem.h"
5858
#include "Common/UserPreferences.h"
5959

60+
#include "GameClient/Display.h"
6061
#include "GameClient/GlobalLanguage.h"
6162

6263
//-----------------------------------------------------------------------------
@@ -195,10 +196,34 @@ float GlobalLanguage::getResolutionFontSizeAdjustment( void ) const
195196

196197
Int GlobalLanguage::adjustFontSize(Int theFontSize)
197198
{
198-
Real adjustFactor = TheGlobalData->m_xResolution / (Real)DEFAULT_DISPLAY_WIDTH;
199+
// TheSuperHackers @tweak xezon 16/08/2025 The size adjustment now also weighs in
200+
// the display height for a balanced rescale on non 4:3 resolutions.
201+
// The aspect ratio scaling is clamped between 1 and 2 to avoid oversizing.
202+
// The scaler no longer clamps at max 2, which makes it work properly for
203+
// 4k Resolutions and beyond.
204+
205+
Real w = TheDisplay->getWidth();
206+
Real h = TheDisplay->getHeight();
207+
const Real aspect = w / h;
208+
Real wScale = w / (Real)DEFAULT_DISPLAY_WIDTH;
209+
Real hScale = h / (Real)DEFAULT_DISPLAY_HEIGHT;
210+
211+
if (aspect > 2.0f)
212+
{
213+
// Recompute width at aspect=2
214+
w = 2.0f * h;
215+
wScale = w / (Real)DEFAULT_DISPLAY_WIDTH;
216+
}
217+
else if (aspect < 1.0f)
218+
{
219+
// Recompute height at aspect=1
220+
h = 1.0f * w;
221+
hScale = h / (Real)DEFAULT_DISPLAY_HEIGHT;
222+
}
223+
224+
Real adjustFactor = (wScale + hScale) * 0.5f;
199225
adjustFactor = 1.0f + (adjustFactor-1.0f) * getResolutionFontSizeAdjustment();
200-
if (adjustFactor<1.0f) adjustFactor = 1.0f;
201-
if (adjustFactor>2.0f) adjustFactor = 2.0f;
226+
if (adjustFactor < 1.0f) adjustFactor = 1.0f;
202227
Int pointSize = REAL_TO_INT_FLOOR(theFontSize*adjustFactor);
203228
return pointSize;
204229
}

0 commit comments

Comments
 (0)