From e845da025a772403110babe7c7b8f01416261a0b Mon Sep 17 00:00:00 2001 From: trompetin17 Date: Tue, 27 May 2025 22:44:49 -0500 Subject: [PATCH] Add deprecation warning to GetTextSize API Adds a runtime warning to `Engine.GetTextSize` indicating that the API is deprecated and will be removed in a future version. This API does not simulate GUI rendering accurately, as it treats markup tags like [color], [font], or [icon] as visible characters. This leads to incorrect size measurements in modern GUI layouts. New recommended alternatives: - Use `Engine.GetGUITextSize(...)` for accurate measurement of raw text blocks, fully simulating GUI rendering. - Use `guiObject.getTextSize()` when working within a specific GUI object, as it accounts for maxWidth, padding (bufferZone), and object constraints. A warning is now emitted at runtime to guide developers toward these updated APIs. --- source/ps/scripting/JSInterface_Main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/ps/scripting/JSInterface_Main.cpp b/source/ps/scripting/JSInterface_Main.cpp index a06575f14f..d4c2c2ea13 100644 --- a/source/ps/scripting/JSInterface_Main.cpp +++ b/source/ps/scripting/JSInterface_Main.cpp @@ -25,6 +25,7 @@ #include "lib/utf8.h" #include "maths/Size2D.h" #include "maths/MD5.h" +#include "ps/CLogger.h" #include "ps/CStrIntern.h" #include "ps/GUID.h" #include "ps/GameSetup/Atlas.h" @@ -87,6 +88,7 @@ int GetFps() CSize2D GetTextSize(const std::string& fontName, const std::wstring& text) { + LOGWARNING("Engine.GetTextSize is deprecated and will be removed in a future version.Use guiObject.GetPreferedTextSize for accurate text sizing or guiObject.getTextSize for sizing within GUI objects."); float width = 0; float height = 0; CStrIntern _fontName(fontName);