Ask a Question related to PHP Development, Design and Development.
-
Zac Hester #1
True Type Fonts (FreeType) - GD - PHP 4.3.2
Hello,
I'm having a problem using the TTF support in GD. I just installed the
latest release of PHP (4.3.2) and the latest version of FreeType (1.3.1).
Everything compiled fine and a call to phpinfo() says it's all installed
exactly as it should be:
GD Support enabled
GD Version bundled (2.0.12 compatible)
FreeType Support enabled
FreeType Linkage with TTF library
GIF Read Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled
I copied a few fonts off of my Windows machine to my web site. Now, I use
the universal demonstration script found on every site showing how to use
TTF support:
<?php
header("Content-type: image/jpeg");
$im = imagecreate(400,30);
$white = imagecolorallocate($im, 255,255,255);
$black = imagecolorallocate($im, 0,0,0);
imagettftext($im, 20, 0, 10, 20, $black,
"/usr/loca/apache/htdocs/systems/fonts/arial.ttf",
"Testing... Omega: &#937;");
imagejpeg($im);
imagedestroy($im);
?>
Running this script only displays a blank, white image 400x30 pixels.
There's no text. I turned off the "Content-Type" header to see if there's
any errors or warnings being generated and it just spits out the image data
like it should. (I have all the default error reporting settings turned
on.)
My next test was to use the imagestring() function in place of the
imagettftext() function. Using that function, the text displays exactly as
expected.
I also used PHP's file_exists() function to make sure I had the path correct
on the font file and it returned a "1"
Just for giggles, I ran a print_r() on the return of imagettftext() (without
the "Content-Type" header) and it reported the following values for the
bounding box:
Array (
[0] => 136397764
[1] => -1077944084
[2] => 136398444
[3] => 136894220
[4] => 5
[5] => 136785624
[6] => 136890096
[7] => 136894828
)
This looks like there's something way messed up with how FreeType is reading
the font file. So, I figure I'm missing something with installing fonts on
my web server. I look around and find a utility for installing font
information for X called ttmkfdir. It just compiles a list of font names so
a font rendering application can use the font files. I installed the
utility and ran it on my font directory. (It ran as expected.) Results:
still nothing. I even tried copying the fonts to the accepted fonts
directory (/usr/share/fonts/truetype) and ran the ttmkfdir program once
again. I changed the path to the font, and still no dice. The bad thing
about this function is that it doesn't error out when the font file is
invalid. (I tried that, too.)
So now, I'm here pleading for anyone's help. If you've ran into this
scenario and fixed it, I'd appreciate any help. If you just have a good
idea as to what I'm missing, I'd also love to hear from you. If it matters,
I'm running Apache 1.3.27 on FreeBSD 4.7.
Thanks, in advnace, for any help anyone can offer.
-Zac
Zac Hester Guest
-
Linux, True Type Fonts and Flash Player
I also have problems about fonts... but not those, which you have. I may help you about fonts. The 'installed fonts' may be two: those in the... -
True Type and Type1 font issue
in my environment we run windows xp and acrobat 5/6 (a mix) we have the need for both the true type and type1 versions of the Minion font. we... -
How to Combine True Type Font with my project
Dear All I've made a dictionary project with director. I've used two true type fonts in my project I wanted to place two true type fonts in... -
True type fonts in Windows 2000
I created a CD-ROM in french. I have problems with accents (èàê) that don't appear properly. I cannot replace my text with bitmap because the... -
#25734 [NEW]: string false type-casts into boolean TRUE
From: rbotzer at yahoo dot com Operating system: MacOS X PHP version: 4.3.3 PHP Bug Type: Feature/Change Request Bug... -
Zac Hester #2
True Type Fonts (FreeType) - GD - PHP 4.3.2
Hello,
I'm having a problem using the TTF support in GD. I just installed the
latest release of PHP (4.3.2) and the latest version of FreeType (1.3.1).
Everything compiled fine and a call to phpinfo() says it's all installed
exactly as it should be:
GD Support enabled
GD Version bundled (2.0.12 compatible)
FreeType Support enabled
FreeType Linkage with TTF library
GIF Read Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled
I copied a few fonts off of my Windows machine to my web site. Now, I use
the universal demonstration script found on every site showing how to use
TTF support:
<?php
header("Content-type: image/jpeg");
$im = imagecreate(400,30);
$white = imagecolorallocate($im, 255,255,255);
$black = imagecolorallocate($im, 0,0,0);
imagettftext($im, 20, 0, 10, 20, $black,
"/usr/loca/apache/htdocs/systems/fonts/arial.ttf",
"Testing... Omega: &#937;");
imagejpeg($im);
imagedestroy($im);
?>
Running this script only displays a blank, white image 400x30 pixels.
There's no text. I turned off the "Content-Type" header to see if there's
any errors or warnings being generated and it just spits out the image data
like it should. (I have all the default error reporting settings turned
on.)
My next test was to use the imagestring() function in place of the
imagettftext() function. Using that function, the text displays exactly as
expected.
I also used PHP's file_exists() function to make sure I had the path correct
on the font file and it returned a "1"
Just for giggles, I ran a print_r() on the return of imagettftext() (without
the "Content-Type" header) and it reported the following values for the
bounding box:
Array (
[0] => 136397764
[1] => -1077944084
[2] => 136398444
[3] => 136894220
[4] => 5
[5] => 136785624
[6] => 136890096
[7] => 136894828
)
This looks like there's something way messed up with how FreeType is reading
the font file. So, I figure I'm missing something with installing fonts on
my web server. I look around and find a utility for installing font
information for X called ttmkfdir. It just compiles a list of font names so
a font rendering application can use the font files. I installed the
utility and ran it on my font directory. (It ran as expected.) Results:
still nothing. I even tried copying the fonts to the accepted fonts
directory (/usr/share/fonts/truetype) and ran the ttmkfdir program once
again. I changed the path to the font, and still no dice. The bad thing
about this function is that it doesn't error out when the font file is
invalid. (I tried that, too.)
So now, I'm here pleading for anyone's help. If you've ran into this
scenario and fixed it, I'd appreciate any help. If you just have a good
idea as to what I'm missing, I'd also love to hear from you. If it matters,
I'm running Apache 1.3.27 on FreeBSD 4.7.
Thanks, in advnace, for any help anyone can offer.
-Zac
Zac Hester Guest
-
Zac Hester #3
Re: True Type Fonts (FreeType) - GD - PHP 4.3.2
Paul,
Thanks for the idea. I tried what you said and used the
imagecreatetruecolor() function and it does the exact same thing. It
creates a blank, white picture.
Thank you for your time,
Zac
"Paul Liversidge" <paul_liversidge@hotmail.com> wrote in message
news:bf26a194.0307032149.379bccf6@posting.google.c om...news:<3f04dfe3$1@news.enetis.net>...> "Zac Hester" <news@planetzac.net> wrote in message(1.3.1).> > Hello,
> >
> > I'm having a problem using the TTF support in GD. I just installed the
> > latest release of PHP (4.3.2) and the latest version of FreeTypeuse> > Everything compiled fine and a call to phpinfo() says it's all installed
> > exactly as it should be:
> >
> > GD Support enabled
> > GD Version bundled (2.0.12 compatible)
> > FreeType Support enabled
> > FreeType Linkage with TTF library
> > GIF Read Support enabled
> > JPG Support enabled
> > PNG Support enabled
> > WBMP Support enabled
> > XBM Support enabled
> >
> > I copied a few fonts off of my Windows machine to my web site. Now, Iuse> > the universal demonstration script found on every site showing how to>> > TTF support:
> >
> > <?php
> > header("Content-type: image/jpeg");
> > $im = imagecreate(400,30);
> > $white = imagecolorallocate($im, 255,255,255);
> > $black = imagecolorallocate($im, 0,0,0);
> > imagettftext($im, 20, 0, 10, 20, $black,
> > "/usr/loca/apache/htdocs/systems/fonts/arial.ttf",
> > "Testing... Omega: &#937;");
> > imagejpeg($im);
> > imagedestroy($im);
> > ?>
> I actually think it's a problem with the GD but I'm only guessing
> having had similar problems with color allocation.
>
> As you've got GD v2 I'd replace the imagecreate with
> imagecreatetruecolor
>
> If that doesn't work, keep the imagecreatetruecolor, GD v2's preferred
> way of creating images and add this line before the imagettftext.
>
> imagefilledrectangle ($im, 0, 0, 399, 29, $white);
>
> imagecreate used to set the background to the first allocated colour,
> white in this example and it seems to work correctly given your
> results. However, in a recent application this didn't work and I had
> to paint the background. This little addition is grasping at straws
> but I think the first one may solve it. :)
Zac Hester Guest
-
Zac Hester #4
Re: True Type Fonts (FreeType) - GD - PHP 4.3.2
Paul,
Thanks for the idea. I tried what you said and used the
imagecreatetruecolor() function and it does the exact same thing. It
creates a blank, white picture.
Thank you for your time,
Zac
"Paul Liversidge" <paul_liversidge@hotmail.com> wrote in message
news:bf26a194.0307032149.379bccf6@posting.google.c om...news:<3f04dfe3$1@news.enetis.net>...> "Zac Hester" <news@planetzac.net> wrote in message(1.3.1).> > Hello,
> >
> > I'm having a problem using the TTF support in GD. I just installed the
> > latest release of PHP (4.3.2) and the latest version of FreeTypeuse> > Everything compiled fine and a call to phpinfo() says it's all installed
> > exactly as it should be:
> >
> > GD Support enabled
> > GD Version bundled (2.0.12 compatible)
> > FreeType Support enabled
> > FreeType Linkage with TTF library
> > GIF Read Support enabled
> > JPG Support enabled
> > PNG Support enabled
> > WBMP Support enabled
> > XBM Support enabled
> >
> > I copied a few fonts off of my Windows machine to my web site. Now, Iuse> > the universal demonstration script found on every site showing how to>> > TTF support:
> >
> > <?php
> > header("Content-type: image/jpeg");
> > $im = imagecreate(400,30);
> > $white = imagecolorallocate($im, 255,255,255);
> > $black = imagecolorallocate($im, 0,0,0);
> > imagettftext($im, 20, 0, 10, 20, $black,
> > "/usr/loca/apache/htdocs/systems/fonts/arial.ttf",
> > "Testing... Omega: &#937;");
> > imagejpeg($im);
> > imagedestroy($im);
> > ?>
> I actually think it's a problem with the GD but I'm only guessing
> having had similar problems with color allocation.
>
> As you've got GD v2 I'd replace the imagecreate with
> imagecreatetruecolor
>
> If that doesn't work, keep the imagecreatetruecolor, GD v2's preferred
> way of creating images and add this line before the imagettftext.
>
> imagefilledrectangle ($im, 0, 0, 399, 29, $white);
>
> imagecreate used to set the background to the first allocated colour,
> white in this example and it seems to work correctly given your
> results. However, in a recent application this didn't work and I had
> to paint the background. This little addition is grasping at straws
> but I think the first one may solve it. :)
Zac Hester Guest
-
David Robley #5
Re: True Type Fonts (FreeType) - GD - PHP 4.3.2
In article <3f09b371$1@news.enetis.net>, [email]news@planetzac.net[/email] says...
OK, but it does say /usr/loca/... where normally it would be> "David Robley" <robleyd@ozemail.com.oz> wrote in message
> news:MPG.19729b96887b724f9896b7@news.spiderweb.com .au...>> > In article <3f04dfe3$1@news.enetis.net>, [email]news@planetzac.net[/email] says...> >> > >
> > > <?php
> > > header("Content-type: image/jpeg");
> > > $im = imagecreate(400,30);
> > > $white = imagecolorallocate($im, 255,255,255);
> > > $black = imagecolorallocate($im, 0,0,0);
> > > imagettftext($im, 20, 0, 10, 20, $black,
> > > "/usr/loca/apache/htdocs/systems/fonts/arial.ttf",
> > Is this a copy/paste? If so, the path looks wrong.
> >
> > <SNIP rest>
> Nope, that's the path to my fonts directory for my site. Just to make sure
> I wasn't insane, I put a file_exists() check in the code to make sure I
> typed the path and filename to the font file correctly. Everything is where
> it should be.
>
> Thank you for your time,
> Zac
/usr/local/....
--
Quod subigo farinam
$email =~ s/oz$/au/o;
David Robley Guest
-
David Robley #6
Re: True Type Fonts (FreeType) - GD - PHP 4.3.2
In article <3f09b371$1@news.enetis.net>, [email]news@planetzac.net[/email] says...
OK, but it does say /usr/loca/... where normally it would be> "David Robley" <robleyd@ozemail.com.oz> wrote in message
> news:MPG.19729b96887b724f9896b7@news.spiderweb.com .au...>> > In article <3f04dfe3$1@news.enetis.net>, [email]news@planetzac.net[/email] says...> >> > >
> > > <?php
> > > header("Content-type: image/jpeg");
> > > $im = imagecreate(400,30);
> > > $white = imagecolorallocate($im, 255,255,255);
> > > $black = imagecolorallocate($im, 0,0,0);
> > > imagettftext($im, 20, 0, 10, 20, $black,
> > > "/usr/loca/apache/htdocs/systems/fonts/arial.ttf",
> > Is this a copy/paste? If so, the path looks wrong.
> >
> > <SNIP rest>
> Nope, that's the path to my fonts directory for my site. Just to make sure
> I wasn't insane, I put a file_exists() check in the code to make sure I
> typed the path and filename to the font file correctly. Everything is where
> it should be.
>
> Thank you for your time,
> Zac
/usr/local/....
--
Quod subigo farinam
$email =~ s/oz$/au/o;
David Robley Guest
-
Zac Hester #7
Re: True Type Fonts (FreeType) - GD - PHP 4.3.2
"David Robley" <robleyd@ozemail.com.oz> wrote in message
news:MPG.1975313961663d9896ba@news.spiderweb.com.a u...sure> In article <3f09b371$1@news.enetis.net>, [email]news@planetzac.net[/email] says...> > "David Robley" <robleyd@ozemail.com.oz> wrote in message
> > news:MPG.19729b96887b724f9896b7@news.spiderweb.com .au...> >> > > In article <3f04dfe3$1@news.enetis.net>, [email]news@planetzac.net[/email] says...
> > > >
> > > > <?php
> > > > header("Content-type: image/jpeg");
> > > > $im = imagecreate(400,30);
> > > > $white = imagecolorallocate($im, 255,255,255);
> > > > $black = imagecolorallocate($im, 0,0,0);
> > > > imagettftext($im, 20, 0, 10, 20, $black,
> > > > "/usr/loca/apache/htdocs/systems/fonts/arial.ttf",
> > >
> > > Is this a copy/paste? If so, the path looks wrong.
> > >
> > > <SNIP rest>
> > Nope, that's the path to my fonts directory for my site. Just to makewhere> > I wasn't insane, I put a file_exists() check in the code to make sure I
> > typed the path and filename to the font file correctly. Everything isYup, that was my mistake. The path wasn't copy/pasted from my code. The>> > it should be.
> >
> > Thank you for your time,
> > Zac
> OK, but it does say /usr/loca/... where normally it would be
> /usr/local/....
>
>
> --
> Quod subigo farinam
>
> $email =~ s/oz$/au/o;
>
important thing is that the path is correct in my code.
Thanks for the reply,
Zac
Zac Hester Guest
-
Zac Hester #8
Re: True Type Fonts (FreeType) - GD - PHP 4.3.2
"David Robley" <robleyd@ozemail.com.oz> wrote in message
news:MPG.1975313961663d9896ba@news.spiderweb.com.a u...sure> In article <3f09b371$1@news.enetis.net>, [email]news@planetzac.net[/email] says...> > "David Robley" <robleyd@ozemail.com.oz> wrote in message
> > news:MPG.19729b96887b724f9896b7@news.spiderweb.com .au...> >> > > In article <3f04dfe3$1@news.enetis.net>, [email]news@planetzac.net[/email] says...
> > > >
> > > > <?php
> > > > header("Content-type: image/jpeg");
> > > > $im = imagecreate(400,30);
> > > > $white = imagecolorallocate($im, 255,255,255);
> > > > $black = imagecolorallocate($im, 0,0,0);
> > > > imagettftext($im, 20, 0, 10, 20, $black,
> > > > "/usr/loca/apache/htdocs/systems/fonts/arial.ttf",
> > >
> > > Is this a copy/paste? If so, the path looks wrong.
> > >
> > > <SNIP rest>
> > Nope, that's the path to my fonts directory for my site. Just to makewhere> > I wasn't insane, I put a file_exists() check in the code to make sure I
> > typed the path and filename to the font file correctly. Everything isYup, that was my mistake. The path wasn't copy/pasted from my code. The>> > it should be.
> >
> > Thank you for your time,
> > Zac
> OK, but it does say /usr/loca/... where normally it would be
> /usr/local/....
>
>
> --
> Quod subigo farinam
>
> $email =~ s/oz$/au/o;
>
important thing is that the path is correct in my code.
Thanks for the reply,
Zac
Zac Hester Guest



Reply With Quote

