Re: Re: imagettftext() test always fails.
| From: | Moriyoshi Koizumi | Date: | Sun, 24 Nov 2002 01:23:14 +0000 |
| Subject: | Re: Re: imagettftext() test always fails. | ||
| References: | 1 | Groups: | php.qa |
| Request: | Send a blank email to php-qa+get-6985@lists.php.net to get a copy of this message | ||
I finally figured out the problem. As GD's native ttf function has wider
range of capability than gdttf.c, it's natural that the test result varies
by configure options.
It is too late for me to notice the difference between imagefttext() and
imagettftext(). Excuse me for wasting your time.
Please run the attached test in a build configured with
--enable-gd-native-ttf. It may give an interesting result...
Moriyoshi
"Ilia A." <ilia@prohost.org> wrote:
> On November 23, 2002 06:23 pm, Moriyoshi Koizumi wrote:
> > > My freetype version is: 6:1:0. It is possible that the 2nd test requires
> > > the latest version of freetype to work, since afaik we have no way inside
> > > PHP to easily determine the used freetype version we should remove the
> > > 2nd part of the test. I will upgrade my freetype library later on today
> > > and I'll let you know whether this test begins to work.
> > >
> > > Ilia
> >
> > Right, we don't even have to detect the freetype version being used in
> > configure time, however I think some notes are needed in the documentation
> > if that's the fact (or my ignorance?) which warns imagettftext() doesn't
> > work with TC images in such case.
> >
>
> I've upgraded freetype to the latest stable release and the problem still
> persists, so it looks like something else is the culprit.
>
> Ilia
>
> > Moriyoshi
> >
> > > > If the test font which I created dedicatedly for the test
> > > > turns out to be irregular to old versions of freetype, I have to
> > > > replace the test by a more proper one, or remove it.
> > > >
> > > > Moriyoshi
> > > >
> > > > > Ilia
> > > > >
> > > > > > If it was not, then my test should be bogus.
> > > > > >
> > > > > > Anyway thanks for the further investigation.
> > > > > >
> > > > > > Moriyoshi
> > > > > >
> > > > > > "Ilia A." <ilia@prohost.org> wrote:
> > > > > > > In your comments you've mentioned that a segmentation fault
> > > > > > > has
> > > > > > > been fixed, on my system it never occured. Even with your patch
> > > > > > > the test still fails. $im = imagecreatetruecolor(256, 256);
> > > > > > > var_dump(testrun($im, $fontfile_8859));
> > > > > > > imagedestroy($im);
> > > > > > >
> > > > > > > returns FALSE instead of true.
> > > > > > >
> > > > > > > My PHP configuration flags that are GD related are as follows:
> > > > > > > --with-gd --with-jpeg-dir --with-png-dir --with-ttf --with-t1lib
> > > > > > >
> > > > > > > Ilia
> > > > > > >
> > > > > > > On November 23, 2002 04:53 pm, Moriyoshi Koizumi wrote:
> > > > > > > > I've just fixed this bug. Now it's ok.
> > > > > > > > Please see my recent patch on gdcache.c for detail.
> > > > > > > >
> > > > > > > > Moriyoshi
> > > > > > > >
> > > > > > > > "Ilia A." <ilia@prohost.org> wrote:
> > > > > > > > > The imagettftext() always fails on my machine and I see
> > > > > > > > > that
> > > > > > > > > it also fails for a number of other people based on QA
> > > > > > > > > reports. The cause of the failure is that when image is
> > > > > > > > > created using the imagecreatetruecolor() function
> > > > > > > > > rather then
> > > > > > > > > imagecreate() addition of the ttf text always fails. Is
> > > > > > > > > this
> > > > > > > > > a bogus test, bug in the code or something else?
> > > > > > > > >
> > > > > > > > > Ilia
>
--TEST-- imagefttext() function test --SKIPIF-- <?php if (!extension_loaded('gd')) { die("skip gd extension not avaliable."); } if (!function_exists("imagefttext")) { die("skip imagefttext() not available."); } ?> --FILE-- <?php $cwd = dirname(__FILE__); $fontfile_8859 = "$cwd/test8859.ttf"; function testrun($im, $fontfile) { $sx = imagesx($im); $sy = imagesy($im); $colour_w = imagecolorallocate($im, 255, 255, 255); $colour_b = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, $sx - 1, $sy - 1, $colour_b); imagefttext($im, $sy * 0.75, 0, 0, $sy - 1, $colour_w, $fontfile, "A", array()); $cnt = 0; for ($y = 0; $y < $sy; ++$y) { for ($x = 0; $x < $sx; ++$x) { if (imagecolorat($im, $x, $y) == $colour_b) { ++$cnt; } } } // imagecolordeallocate($im, $colour_w); // imagecolordeallocate($im, $colour_b); return ($cnt < ($sx * $sy)); } $im = imagecreate(256, 256); var_dump(testrun($im, $fontfile_8859)); imagedestroy($im); $im = imagecreatetruecolor(256, 256); var_dump(testrun($im, $fontfile_8859)); imagedestroy($im); ?> --EXPECT-- bool(true) bool(true)
--TEST-- imagefttext() function test --SKIPIF-- <?php if (!extension_loaded('gd')) { die("skip gd extension not avaliable."); } if (!function_exists("imagefttext")) { die("skip imagefttext() not available."); } ?> --FILE-- <?php $cwd = dirname(__FILE__); $fontfile_8859 = "$cwd/test8859.ttf"; function testrun($im, $fontfile) { $sx = imagesx($im); $sy = imagesy($im); $colour_w = imagecolorallocate($im, 255, 255, 255); $colour_b = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, $sx - 1, $sy - 1, $colour_b); imagefttext($im, $sy * 0.75, 0, 0, $sy - 1, $colour_w, $fontfile, "A", array()); $cnt = 0; for ($y = 0; $y < $sy; ++$y) { for ($x = 0; $x < $sx; ++$x) { if (imagecolorat($im, $x, $y) == $colour_b) { ++$cnt; } } } // imagecolordeallocate($im, $colour_w); // imagecolordeallocate($im, $colour_b); return ($cnt < ($sx * $sy)); } $im = imagecreate(256, 256); var_dump(testrun($im, $fontfile_8859)); imagedestroy($im); $im = imagecreatetruecolor(256, 256); var_dump(testrun($im, $fontfile_8859)); imagedestroy($im); ?> --EXPECT-- bool(true) bool(true)