GDF Fonts

This tutorial will cover GD string fonts and gdf fonts. Imagestring uses built in draw fonts for writing on an image. gdf fonts can be created in order to draw a font onto an image. The basic code is:
imagestring($im, size, x, y, "text", $color);
where sizes are from 1-5. As you can see from the example, they are rather small. imagestringup is used for the sideways word.
Right click, select all, ctrl+c to copy.
These built in fonts, as you can see, are rather small. People have used them for visitor counters to their web site, or a clock, or sql stuff, or for notes on tutes (as in the loop tute). They are not good for logos. However there is another alternative with using gdf fonts. A drawback to these are that there are few on line and many of them too are small, and gdf fonts cannot be sized. Whatever size they are is the size they have to be used at, so they were hardly ever used. But now I've discovered we do have a way to use them (and also to create them!). This is fun now. First, here is an example of some gdf fonts. As you can see they vary in size from tiny to huge with large spaces inbetween the letters. These are some on line addys where you can get some gdf fonts.

Freetowne.com
skylink
tahg.org

Before getting to the fun part, I want to explain how to use them.
Right click, select all, ctrl+c to copy.
The above example uses the anonymous.gdf font. These also use imagestring to write the string, but you first need to load the font.
$font = imageloadfont("anonymous.gdf");
imagestring($image, $font, 10, 0, "HELLO", $red);
Here the sequence is $image, $font, x, y, text, color (no size is specified). In this example the first line uses a red color. The difference between these fonts and ttf fonts is that you can use IMG_COLOR_BRUSHED or IMG_COLOR_STYLED with these. The second line is brushed. But the size changes depending on the size of your brush. To keep it this size, you must now write out the word letter by letter. The last Hello above is using IMG_COLOR_STYLED.
You can use the code to the below to get the size of the font as a base to work with in placing them. It's not perfect but it helps.
Right click, select all, ctrl+c to copy.
The above script will output:
Font height: 43
Font width: 23
While reading up on the gdf fonts on line, I found that there is a way to make your own gdf fonts. If you want to make a full font, they will probably have to be small as you can only put them on one line, but if you want to use only a few letters for a logo say, then you can make them larger (resize) and just make the font with those letters.
On the right are the font-maker tool, script for the tool, source of the tool, and sample font image to test the tool. Just take the image and follow the directions on the tool. The image must be uploaded to your PC. You cannot use a URL on the tool. It will create a font in about 1 second and download it to your pc. You can then upload it to your server. All fonts put through the tool are named font.gdf. You need to rename them. Font Maker
Font Maker Text
Source.puremango.co
font image

Click image to see the size.
I experimented with sizes and made this partial font (on the left) using the paint program (it has a removable grid). It seems if you do not make a full font, it will create the font in the same size as the image. I resized the image to make the smaller version of the font. You can use php, image magick, or a paint program to draw these fonts. You can draw them on a grid, but the grid must not be black. The tool ignores any color except black.
Then I decided to try a dingbat. Using Sally's Teddy, I tweaked the code a bit to get 3 images.
I put the above image through the font maker tool (3 characters, first character A, width 169, height 209). The first font I got did not turn out well as can be seen on the left image below. Then I took the above image to IM and gave it a black threshold of 100% and put it through the font tool again. Got better results as seen in the image on the right below. Click images for a better view.
Below is the teddy brushed and styled, with the whites of the eyes drawn on.
Right click, select all, ctrl+c to copy.
Teddy gdf
Red Tile
I just came across this tool on line for creating gdf fonts from ttf fonts that are installed on your pc. If you download the tool, Windows font to php font tool,, save it before you run it or it will be gone the next time you go to use it. It is simple to use, but again the gdf fonts may be smaller than you would like them to be. Still it is worth trying out. There is also a tool on that page to view gdf fonts.
I just figured out how to outline GDF fonts from the ttf outline codes. I also made this font with the GDF font tool. Not too small. Font Brush
Right click, select all, ctrl+c to copy.
Lesson 8 Page 1