Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GD Fonts 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I am putting text into pictures using GD but I want a different font from the one available. I know the font can be changed but is there a resource where additional fonts can be downloaded. I could create my own but that could be re-inventing the wheel.

Keith
 
the php manual suggests these


Free Type FreeType 2 T1lib » ftp://sunsite.unc.edu/pub/Linux/libs/graphics/) Support for Postscript Type 1 fonts.

additionally GD supports all truetype fonts so you should just be able to point at an existing font on your system
 
you can just upload a ttf file (subject to licence terms). or download any of the fonts in the libraries linked to above and upload them to your website.
 
I am being a bit numbe here, I think. Where are the fonts on the links provided above?
I am developing on a local server so licence not a problem at this stage. I have put the 'verdana.ttf' file in the same dir as the php script.

The original code
Code:
$smallim = imagecreatetruecolor(300, 400 );
imagecopyresampled($smallim,$im,0,0,0,0,300,400,562, 400);
$culler2 = imagecolorallocate ($im,0,0,0);
imagestring($smallim, [red]2[/red], 10, 160, $TEXT1, $culler2);
imagejpeg($smallim);

Add the font load and it goes udders up - no pic display.

Code:
$smallim = imagecreatetruecolor(300, 400 );
imagecopyresampled($smallim,$im,0,0,0,0,300,400,562, 400);
[red]$font = imageloadfont("verdana.ttf");[/red]
$culler2 = imagecolorallocate ($im,0,0,0);
imagestring($smallim, [red]$font[/red], 10, 160, $TEXT1, $culler2);
imagejpeg($smallim);

I have seen programs for converting Windows fonts to GD but is it necessary and if so could you point me to a resource.


Keith
 
have you compiled php to support ttf's ?

and if you want to use ttf's i'd use imagettftext() rather than imageloadfont(). the php manual is great on this stuff.

on the libs: i had thought/remembered that these sites included not just the libraries but sample fonts too. guess i was wrong. i'd bet that googling for Freetype fonts would bring some up.

be careful with changing architectures. i don't think the same font will work across platform necessarily.
 
I am sure you keep inventing these commands just to make me feel inadequate(lol). I will give that a try and see how it goes, thanks.
Code:
the php manual is great on this stuff
Touche
I only use PHP for image manipulation so am not in the habit of reading the manual. I will when time permits but I am a long way off retirement at the moment.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top