This commit is contained in:
Thomas Peterson 2025-11-11 12:44:22 +01:00
parent 2d631411cb
commit 96cd1ea48e

View File

@ -125,6 +125,9 @@ class TextRenderer
$b = (int) ($this->colorB * 255); $b = (int) ($this->colorB * 255);
// Render text to surface with anti-aliasing (blended mode for smooth text) // Render text to surface with anti-aliasing (blended mode for smooth text)
if (strlen($text) < 1) {
return;
}
$surface = ttf_render_text_blended($this->font, $text, $r, $g, $b); $surface = ttf_render_text_blended($this->font, $text, $r, $g, $b);
if (!$surface) { if (!$surface) {
return; return;
@ -144,7 +147,7 @@ class TextRenderer
'x' => $x, 'x' => $x,
'y' => $y, 'y' => $y,
'w' => $textSize['w'], 'w' => $textSize['w'],
'h' => $textSize['h'] 'h' => $textSize['h'],
]); ]);
// Note: Texture and surface are automatically cleaned up by PHP resource destructors // Note: Texture and surface are automatically cleaned up by PHP resource destructors
@ -165,7 +168,9 @@ class TextRenderer
$r = (int) ($this->colorR * 255); $r = (int) ($this->colorR * 255);
$g = (int) ($this->colorG * 255); $g = (int) ($this->colorG * 255);
$b = (int) ($this->colorB * 255); $b = (int) ($this->colorB * 255);
if (strlen($text) < 1) {
return null;
}
$surface = ttf_render_text_blended($this->font, $text, $r, $g, $b); $surface = ttf_render_text_blended($this->font, $text, $r, $g, $b);
if (!$surface) { if (!$surface) {
return null; return null;