Package: php7.4-gd
Version: 7.4.11-1
Severity: normal
X-Debbugs-Cc: t...@mirbsd.de

I’m running the following script:

php -r '
        $text = "2020-12-23T13:25:44Z";
        $font = "Inconsolatazi4varl_qu-Regular.otf";    // attached
        $fontsize = 14;
        $bbox = imageftbbox($fontsize, 0, $font, $text);
        $ascender = abs($bbox[7]) /* +1 */;
        $descender = abs($bbox[1]);
        $size_w = abs($bbox[0]) + abs($bbox[2]);
        $size_h = $ascender + $descender;
        $x = -$bbox[0];
        $y = $ascender;
//print_r(array("bbox"=>$bbox,"ascender"=>$ascender,"descender"=>$descender,"size_w"=>$size_w,"size_h"=>$size_h,"x"=>$x,"y"=>$y));
        $im = imagecreatetruecolor($size_w, $size_h);
        $bgcol = imagecolorallocate($im, 0xDD, 0xDD, 0xDD);
        $fgcol = imagecolorallocate($im, 0x00, 0x00, 0x23);
        imagefilledrectangle($im, 0, 0, $size_w - 1, $size_h - 1, $bgcol);
        imagefttext($im, $fontsize, 0, $x, $y, $fgcol, $font, $text);
        imagetruecolortopalette($im, FALSE, 256);
        imagepng($im, NULL, 9);
' >TS.png

The values I get are:

Array
(
    [bbox] => Array
        (
            [0] => 1
            [1] => 0
            [2] => 185
            [3] => 0
            [4] => 185
            [5] => -11
            [6] => 1
            [7] => -11
        )   

    [ascender] => 11
    [descender] => 0
    [size_w] => 186
    [size_h] => 11
    [x] => -1
    [y] => 11
)

However, these are too small. At least the upper horizontal bar
of the ‘T’ is completely cut off, and (as can be seen when the
/* +1 */ is uncommented) *all* digits have *significant* black
in the topmost line (ascender=12).

Adding 2 to both descender and ascender shows that that’s it.

I suspect rounding to be at fault: the bounding box is most
likely provided via floating point, then cut down to integers.
When dealing with bounding boxen, the correct rounding method
to use is “away from 0”, so that fractional pixels will also
be present.


-- Package-specific info:
==== Additional PHP 7.4 information ====

++++ PHP @PHP_VERSION SAPI (php7.4query -S): ++++

++++ PHP 7.4 Extensions (php7.4query -M -v): ++++

++++ Configuration files: ++++
**** /etc/php/7.4/mods-available/gd.ini ****
extension=gd.so


-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'oldstable-updates'), (500, 
'buildd-unstable'), (500, 'unstable'), (500, 'oldstable'), (1, 
'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.9.0-4-amd64 (SMP w/2 CPU threads)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/lksh
Init: sysvinit (via /sbin/init)

Versions of packages php7.4-gd depends on:
ii  libc6          2.31-6
ii  libgd3         2.3.0-2
ii  php-common     2:76
ii  php7.4-common  7.4.11-1
ii  ucf            3.0043

php7.4-gd recommends no packages.

php7.4-gd suggests no packages.

Versions of packages php7.4-common depends on:
ii  libc6       2.31-6
ii  libffi7     3.3-5
ii  libssl1.1   1.1.1i-1
ii  php-common  2:76
ii  ucf         3.0043

Versions of packages php7.4-cli depends on:
ii  libargon2-1      0~20171227-0.2
ii  libc6            2.31-6
ii  libedit2         3.1-20191231-2
ii  libmagic1        1:5.39-3
ii  libpcre2-8-0     10.36-2
ii  libsodium23      1.0.18-1
ii  libssl1.1        1.1.1i-1
ii  libxml2          2.9.10+dfsg-6.3+b1
ii  mime-support     3.66
ii  php7.4-common    7.4.11-1
ii  php7.4-json      7.4.11-1
ii  php7.4-opcache   7.4.11-1
ii  php7.4-readline  7.4.11-1
ii  tzdata           2020d-1
ii  ucf              3.0043
ii  zlib1g           1:1.2.11.dfsg-2

Versions of packages php7.4-cli suggests:
ii  php-pear  1:1.10.9+submodules+notgz-1.1

Versions of packages libapache2-mod-php7.4 depends on:
ii  apache2-bin [apache2-api-20120211]  2.4.46-2
ii  libargon2-1                         0~20171227-0.2
ii  libc6                               2.31-6
ii  libmagic1                           1:5.39-3
ii  libpcre2-8-0                        10.36-2
ii  libsodium23                         1.0.18-1
ii  libssl1.1                           1.1.1i-1
ii  libxml2                             2.9.10+dfsg-6.3+b1
ii  mime-support                        3.66
ii  php7.4-cli                          7.4.11-1
ii  php7.4-common                       7.4.11-1
ii  php7.4-json                         7.4.11-1
ii  php7.4-opcache                      7.4.11-1
ii  tzdata                              2020d-1
ii  ucf                                 3.0043
ii  zlib1g                              1:1.2.11.dfsg-2

Versions of packages libapache2-mod-php7.4 recommends:
ii  apache2  2.4.46-2

Versions of packages libapache2-mod-php7.4 suggests:
ii  php-pear  1:1.10.9+submodules+notgz-1.1

-- no debconf information

Attachment: Inconsolatazi4varl_qu-Regular.otf
Description: application/vnd.ms-opentype

Reply via email to