Re: [GD-DEVEL] Problem with TTF file
[email protected] ("Marco van Oostende") Sat, 18 Oct 2008 18:06:20 +0200
| Newsgroups | php.gd.devel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]>: > Hi, > > On Thu, 16 Oct 2008 21:14:43 +0200, "Marco van Oostende" <[email protected]> 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() > ?> > >