5252// -----------------------------------------------------------------------------
5353#include " PreRTS.h"
5454
55+ #include " Common/AddonCompat.h"
5556#include " Common/INI.h"
5657#include " Common/Registry.h"
5758#include " Common/FileSystem.h"
6566// -----------------------------------------------------------------------------
6667GlobalLanguage *TheGlobalLanguageData = NULL ; // /< The global language singalton
6768
69+ static const LookupListRec ResolutionFontSizeMethodNames[] =
70+ {
71+ { " CLASSIC" , GlobalLanguage::ResolutionFontSizeMethod_Classic },
72+ { " STRICT" , GlobalLanguage::ResolutionFontSizeMethod_Strict },
73+ { " BALANCED" , GlobalLanguage::ResolutionFontSizeMethod_Balanced },
74+ { NULL , 0 }
75+ };
76+
6877static const FieldParse TheGlobalLanguageDataFieldParseTable[] =
6978{
7079 { " UnicodeFontName" , INI::parseAsciiString,NULL , offsetof ( GlobalLanguage, m_unicodeFontName ) },
@@ -73,7 +82,7 @@ static const FieldParse TheGlobalLanguageDataFieldParseTable[] =
7382 { " MilitaryCaptionSpeed" , INI::parseInt, NULL , offsetof ( GlobalLanguage, m_militaryCaptionSpeed ) },
7483 { " UseHardWordWrap" , INI::parseBool, NULL , offsetof ( GlobalLanguage, m_useHardWrap) },
7584 { " ResolutionFontAdjustment" , INI::parseReal, NULL , offsetof ( GlobalLanguage, m_resolutionFontSizeAdjustment) },
76-
85+ { " ResolutionFontSizeMethod " , INI::parseLookupList, ResolutionFontSizeMethodNames, offsetof ( GlobalLanguage, m_resolutionFontSizeMethod) },
7786 { " CopyrightFont" , GlobalLanguage::parseFontDesc, NULL , offsetof ( GlobalLanguage, m_copyrightFont ) },
7887 { " MessageFont" , GlobalLanguage::parseFontDesc, NULL , offsetof ( GlobalLanguage, m_messageFont) },
7988 { " MilitaryCaptionTitleFont" , GlobalLanguage::parseFontDesc, NULL , offsetof ( GlobalLanguage, m_militaryCaptionTitleFont) },
@@ -120,6 +129,7 @@ GlobalLanguage::GlobalLanguage()
120129 m_militaryCaptionSpeed = 0 ;
121130 m_useHardWrap = FALSE ;
122131 m_resolutionFontSizeAdjustment = 0 .7f ;
132+ m_resolutionFontSizeMethod = ResolutionFontSizeMethod_Balanced;
123133 m_militaryCaptionDelayMS = 750 ;
124134 // End Add
125135
@@ -196,38 +206,76 @@ float GlobalLanguage::getResolutionFontSizeAdjustment( void ) const
196206
197207Int GlobalLanguage::adjustFontSize (Int theFontSize)
198208{
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 )
209+ Real adjustFactor;
210+
211+ switch (m_resolutionFontSizeMethod)
212212 {
213- // Recompute width at aspect=2
214- w = 2 .0f * h;
215- wScale = w / (Real)DEFAULT_DISPLAY_WIDTH;
213+ default :
214+ case ResolutionFontSizeMethod_Classic:
215+ {
216+ // TheSuperHackers @info The original font scaling for this game.
217+ // Can be useful for not breaking legacy Addons and Mods but scales poorly.
218+ adjustFactor = TheDisplay->getWidth () / (Real)DEFAULT_DISPLAY_WIDTH;
219+ adjustFactor = 1 .0f + (adjustFactor - 1 .0f ) * getResolutionFontSizeAdjustment ();
220+ if (adjustFactor > 2 .0f )
221+ adjustFactor = 2 .0f ;
222+ break ;
216223 }
217- else if (aspect < 1 . 0f )
224+ case ResolutionFontSizeMethod_Strict:
218225 {
219- // Recompute height at aspect=1
220- h = 1 .0f * w;
221- hScale = h / (Real)DEFAULT_DISPLAY_HEIGHT;
226+ // TheSuperHackers @feature The strict method scales fonts based on the smallest screen
227+ // dimension so they scale independent of aspect ratio.
228+ const Real wScale = TheDisplay->getWidth () / (Real)DEFAULT_DISPLAY_WIDTH;
229+ const Real hScale = TheDisplay->getHeight () / (Real)DEFAULT_DISPLAY_HEIGHT;
230+ adjustFactor = min (wScale, hScale);
231+ adjustFactor = 1 .0f + (adjustFactor - 1 .0f ) * getResolutionFontSizeAdjustment ();
232+ break ;
222233 }
234+ case ResolutionFontSizeMethod_Balanced:
235+ {
236+ // TheSuperHackers @feature The balanced method evenly weighs the display width and height
237+ // for a balanced rescale on non 4:3 resolutions. The aspect ratio scaling is clamped
238+ // between 1 and 2 to avoid oversizing.
239+ Real w = TheDisplay->getWidth ();
240+ Real h = TheDisplay->getHeight ();
241+ const Real aspect = w / h;
242+ Real wScale = w / (Real)DEFAULT_DISPLAY_WIDTH;
243+ Real hScale = h / (Real)DEFAULT_DISPLAY_HEIGHT;
223244
224- Real adjustFactor = (wScale + hScale) * 0 .5f ;
225- adjustFactor = 1 .0f + (adjustFactor-1 .0f ) * getResolutionFontSizeAdjustment ();
226- if (adjustFactor < 1 .0f ) adjustFactor = 1 .0f ;
245+ if (aspect > 2 .0f )
246+ {
247+ // Recompute width at aspect=2
248+ w = 2 .0f * h;
249+ wScale = w / (Real)DEFAULT_DISPLAY_WIDTH;
250+ }
251+ else if (aspect < 1 .0f )
252+ {
253+ // Recompute height at aspect=1
254+ h = 1 .0f * w;
255+ hScale = h / (Real)DEFAULT_DISPLAY_HEIGHT;
256+ }
257+ adjustFactor = (wScale + hScale) * 0 .5f ;
258+ adjustFactor = 1 .0f + (adjustFactor - 1 .0f ) * getResolutionFontSizeAdjustment ();
259+ break ;
260+ }
261+ }
262+
263+ if (adjustFactor < 1 .0f )
264+ adjustFactor = 1 .0f ;
227265 Int pointSize = REAL_TO_INT_FLOOR (theFontSize*adjustFactor);
228266 return pointSize;
229267}
230268
269+ void GlobalLanguage::parseCustomDefinition ()
270+ {
271+ if (addon::HasFullviewportDat ())
272+ {
273+ // TheSuperHackers @tweak xezon 19/08/2025 Force the classic font size adjustment for the old
274+ // 'Control Bar Pro' Addons because they use manual font upscaling in higher resolution packages.
275+ m_resolutionFontSizeMethod = ResolutionFontSizeMethod_Classic;
276+ }
277+ }
278+
231279FontDesc::FontDesc (void )
232280{
233281 name = " Arial Unicode MS" ; // /<name of font
0 commit comments