xref: /PHP-8.4/ext/gd/tests/gh17373.phpt (revision ec90367c)
1--TEST--
2Bug GH-17373 (imagefttext() ignores clipping rect for palette images)
3--EXTENSIONS--
4gd
5--FILE--
6<?php
7$im = imagecreate(64, 32);
8$bg = imagecolorallocate($im, 0, 0, 0);
9$fg = imagecolorallocate($im, 255, 255, 255);
10imagefilledrectangle($im, 0, 0, 63, 31, $bg);
11imagesetclip($im, 32, 0, 63, 31);
12imagefttext($im, 16, 0, 10, 23, $fg, __DIR__ . "/Tuffy.ttf", "hello");
13
14imagesetclip($im, 0, 0, 63, 31);
15$count = 0;
16for ($j = 0; $j < 31; $j++) {
17    for ($i = 0; $i < 31; $i++) {
18        if (imagecolorat($im, $i, $j) !== $bg) {
19            $count++;
20        }
21    }
22}
23var_dump($count);
24?>
25--EXPECT--
26int(0)
27