Skip to content

Commit 3a95cef

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

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@
5252
//-----------------------------------------------------------------------------
5353
#include "PreRTS.h"
5454

55+
#include "Common/FileSystem.h"
5556
#include "Common/INI.h"
5657
#include "Common/Registry.h"
58+
59+
#include "GameClient/Display.h"
5760
#include "GameClient/GlobalLanguage.h"
58-
#include "Common/FileSystem.h"
5961

6062
//-----------------------------------------------------------------------------
6163
// DEFINES ////////////////////////////////////////////////////////////////////
@@ -191,10 +193,34 @@ void GlobalLanguage::parseFontFileName( INI *ini, void * instance, void *store,
191193

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

0 commit comments

Comments
 (0)