Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imageftbbox regression between 2.2.5-5.2 and 2.3.0-2 #814

Open
mirabilos opened this issue Jan 29, 2022 · 9 comments
Open

imageftbbox regression between 2.2.5-5.2 and 2.3.0-2 #814

mirabilos opened this issue Jan 29, 2022 · 9 comments

Comments

@mirabilos
Copy link

Describe the bug
imageftbbox returns a too small bounding box in libgd3 2.3.0-2 (Debian bullseye, testing/bookworm, sid) for all PHP versions

To Reproduce
See php/php-src#8001

If I LD_PRELOAD libgd3 2.2.5-5.2 (Debian buster) libgd.so.3.0.5, the correct bounding box is returned.

Expected behavior
[ascender] => 13
[descender] => 1

Actual results
[ascender] => 11
[descender] => 0

Environment (please complete the following information):

  • OS: Debian bullseye
  • Versio: 2.2.5 (works), 2.3.0 (broken)
  • All libraries used by GD and their respective version (eg. Freetype 2.2.5) Freetype 2.10.4+dfsg-1

Additional context
Downstream bugreport: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980759

@pierrejoye
Copy link
Contributor

Thanks for the report. :)

Do you use RAQM?

Could you attach the font and script here too please?

@mirabilos
Copy link
Author

Unfortunately, http://www.mirbsd.org/wtf.cgi?q=RAQM

Sure.
x.zip

<?php
$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;
$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);
if (0) {
	imagepng($im, NULL, 9);
} else {
	print_r(array(
		"bbox" => $bbox,
		"ascender" => $ascender,
		"descender" => $descender,
		"size_w" => $size_w,
		"size_h" => $size_h,
		"x" => $x,
		"y" => $y,
	    ));
}

@pierrejoye
Copy link
Contributor

@mirabilos RAQM is an optional library for complex text layout (vertical, RTL and co), https://github.com/HOST-Oman/libraqm

I am not sure it is displayed in phpinfo but in the configure line.

@mirabilos
Copy link
Author

mirabilos commented Jan 30, 2022 via email

@pierrejoye
Copy link
Contributor

pierrejoye commented Jan 30, 2022 via email

@mirabilos
Copy link
Author

mirabilos commented Jan 30, 2022 via email

@pierrejoye
Copy link
Contributor

pierrejoye commented Jan 30, 2022 via email

@mirabilos
Copy link
Author

mirabilos commented Jan 30, 2022 via email

@mirabilos
Copy link
Author

Uhm, careful ping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants