Re: [GD-DEVEL] Problem with TTF file
| From: | Marco van Oostende | Date: | Sat, 18 Oct 2008 16:06:20 +0000 |
| Subject: | Re: [GD-DEVEL] Problem with TTF file | ||
| References: | 1 2 | Groups: | php.gd.devel |
| Request: | Send a blank email to php-gd-devel+get-487@lists.php.net to get a copy of this message | ||
Hi,
This strengthens the conclusion that it is somehow version related. I
tested it on another installation of CentOS5 (same as Redhat RHEL5),
and it fails there too. Is there anyone who can somehow debug what is
actually failing, or able to point me in a direction of doing this
myself?
Thanks,
Marco van Oostende
2008/10/18 Takeshi Abe <tabe@fixedpoint.jp>:
> Hi,
>
> On Thu, 16 Oct 2008 21:14:43 +0200, "Marco van Oostende" <moostende@gmail.com>
> wrote:
>> function create_image() {
>> header('Content-type: image/png');
>> $box = ImageTTFbbox($this->fontsize, 0, $this->fontfile, $this->article);
>> $src_img = ImageCreate(($box[2]+11), (abs($box[7]-$box[1])+6));
>> $black = ImageColorAllocate($src_img, 0x00, 0x00, 0x00);
>> $white = ImageColorAllocate($src_img, 0xff, 0xff, 0xff);
>> ImageFill($src_img, 0, 0, $white);
>> ImageColorTransparent($src_img, $white);
>> ImageTTFText($src_img, $this->fontsize, 0, 3, abs($box[7]), $black,
>> $this->fontfile, $this->article);
>> ImagePNG($src_img);
>> ImageDestroy($src_img);
>> }
> (snip)
>>
>> The GPL font file I use can be downloaded from 'grandzebu dot net
>> slash informatique slash codbar slash ean13 dot ttf' and the string to
>> put in $this->article for testing is 3FJQRLA*cbgahj+
> The above function seems to work well on my Debian lenny with php5-gd
> (php 5.2.6 + gd 2.0.35), resulting the attached png.
>
> Cheers,
> -- Takeshi Abe
>
> <?php
> class X {
>
> private $fontsize = 30;
> private $fontfile = "/home/tabe/ean13.ttf";
> private $article = "3FJQRLA*cbgahj+";
>
> function __construct()
> {
> }
>
> function create_image() {
> header('Content-type: image/png');
> $box = ImageTTFbbox($this->fontsize, 0, $this->fontfile, $this->article);
> $src_img = ImageCreate(($box[2]+11), (abs($box[7]-$box[1])+6));
> $black = ImageColorAllocate($src_img, 0x00, 0x00, 0x00);
> $white = ImageColorAllocate($src_img, 0xff, 0xff, 0xff);
> ImageFill($src_img, 0, 0, $white);
> ImageColorTransparent($src_img, $white);
> ImageTTFText($src_img, $this->fontsize, 0, 3, abs($box[7]), $black,
> $this->fontfile, $this->article);
> ImagePNG($src_img);
> ImageDestroy($src_img);
> }
> }
> $x = new X();
> $x->create_image()
> ?>
>
>