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.
This commit is contained in:
trompetin17 2025-05-27 22:44:49 -05:00
parent b42a2b9adb
commit e845da025a
No known key found for this signature in database
GPG key ID: 6C585FA3FC5DB179

View file

@ -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);