#!/usr/local/bin/perl -w use GD; $fontDir = '/full/path/to/fonts/dir/'; @allFontNames = (); #will need to adjust these depending on how many names you will want t +o show up $height = 800; $width = 320; # create a new image #W,H #make it wide enough for whatever text you are putting in (2 rows) #make it long enough to allow all fonts to show up #$im = new GD::Image(150, 800);#single row $im = new GD::Image($width, $height);#double row #set the background color so we have something to contrast against $im->colorAllocate(255,255,255); #set what will be the font color $black = $im->colorResolve(0,0,0); #get all the fonts from your directory opendir(FONT_DIR,$fontDir); @allFontNames = grep { $_ ne "." and $_ ne ".." } readdir FONT_DIR; closedir(FONT_DIR); #now loop over that array and use that font, and also print out its na +me #check to see if we exceed the height that set, if so, then go over to + two rows $currentLeft = 5; $currentTop = 20; foreach(@allFontNames){ #check to see that we haven't passed our height if($currentTop > $height){ #reset it to write to a new row $currentLeft += 195; $currentTop = 20; } #color,full path, height in pixels, rotation, left, top, text to p +rint $im->stringTTF($black, $fontDir . $_, 12, 0, $currentLeft, $currentTop, $_) or die "Wassup ma scrollays:$!\n"; $currentTop += 20; } open(IMAGE, ">fonts.png") or die; binmode IMAGE; print IMAGE $im->png;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: creating an image of all of your fonts
by Aristotle (Chancellor) on Mar 11, 2003 at 02:38 UTC | |
by AssFace (Pilgrim) on Mar 11, 2003 at 02:56 UTC | |
|
Re: creating an image of all of your fonts
by jasonk (Parson) on Mar 10, 2003 at 21:20 UTC | |
|
Re: creating an image of all of your fonts
by zentara (Cardinal) on Mar 11, 2003 at 12:58 UTC |