gd-text icon indicating copy to clipboard operation
gd-text copied to clipboard

PHP 8 Deprecated function: Implicit conversion from float 38.5 to int loses precision in GDText\Box->drawInternal() (line 400 of /app/vendor/stil/gd-text/src/Box.php).

Open kaszarobert opened this issue 1 year ago • 1 comments

Deprecated function: Implicit conversion from float 38.5 to int loses precision in GDText\Box->drawInternal() (line 400 of /app/vendor/stil/gd-text/src/Box.php). GDText\Box->drawInternal(38.5, 162.6, Object, ' ') (Line: 328) GDText\Box->draw('
Total: 2 000 mm') (Line: 1288)

$box = new Box($image); $box->setFontFace($font_path); $box->setFontColor(new Color(255, 255, 255)); $box->setLineHeight(1.5); $box->setBox(0, 0, 100, 100); $box->setTextAlign('center', 'top'); $box->draw($textToUse);

With line height 1.5 I get this deprecation warning all the times

kaszarobert avatar Mar 20 '25 14:03 kaszarobert

In drawInternal() the $x and $y parameters for imagefttext() should be modified to:

            (int) round($x),
            (int) round($y),

And the problem is fixed

kaszarobert avatar Mar 20 '25 14:03 kaszarobert