DJ Mike's Tutorials: PHP


< ^ >

Using True Type Fonts

Using True Type Fonts

Unlike when you use built in fonts, when you use TTF's (True Type Fonts), you have to find and install the fonts yourself. Finding fonts is no problem though. Google "Free Fonts" and you'll see more than a million sites that have free fonts. When you find one you like have to load it into your a web site. The link to the font will be to either a .ttf file or a .zip file. Either way, if you are a webtv user, clicking the link will get you a "cannot use" error. Click your Go To button abd "Show Last" to get the URL to get the URL to upload to your site. Computer users either left click and "Save this file to disk" or right click and "Save Target As" to save it to you computer then upload it to your web site. If you were to do a Halloween themed image, you may decide to use the Groovy Ghosties font that I'll use for my first example.

imageTTFtext()

To write text to an image, you use the imageTTFtext() function. The imageTTFtext() function requires eight arguments: an image resource, an angle in degrees, a size argument (height of character in pixels), x and y starting cooridinates, a color resource, the path to the font and a text string. Note that you have to use the path to the font. A full URL will not work. You cannot use a font that is not on your own site.

imageTTFtext( $image, $size, $angle, $x, $y, $color, "Text string");

Show Image Show Source Code

Show Image Show Source Code

With imagestringup(), you can only make text horizontally or vertically but with imageTTFtext(), you can use the angle argument to rotate the text to any angle that you want:



Show Image Show Source Code

Show Image Show Source Code

3D text

To create a 3D effect for the text, make the same text string two or three times off setting the first one up and left and the middle (if you have three) down and right. The is similar to the technique to emboss using ImageMagick. For the banner at the top of this page, I used the blank banner I made to demonstrate rectangles and added code for 3D text



Show Image Show Source Code

Show Image Show Source Code

Beveled Ellipse With 3D text

You know how to make ellipses and I showed a few examples of color gradient images. For this example, I loop through concentric ellipses to make a 3D effect:



Show Image Show Source Code

Show Image Show Source Code


< ^ >


Was this webpage useful to you? You can support this website by donating.


Created by DJ Mike from Santa Barbara

DJ Mike


<a href="http://www.statcounter.com/" target="_blank"> <img src="http://c5.statcounter.com/counter.php?sc_project=1321035&java=0&security=da2193dc" alt="counter free hit invisible" border="0" /></a>