#!/usr/bin/perl -w use strict; # untested; merely to prove a point use GD; use File::Spec; use constant FONT_PATH => '/full/path/to/fonts/dir/'; use constant HEIGHT => 800; use constant WIDTH => 320 use constant COL_WIDTH => 195; use constant LINE_HEIGHT => 20; use constant LEFT => 5; use constant TOP => 20; my $im = GD::Image->(WIDTH, HEIGHT); $im->colorAllocate(255,255,255); my $black = $im->colorResolve(0,0,0); my @font_name = do { opendir my($dh), FONT_PATH or die "Couldn't open ", FONT_PATH, ": $!\n"; grep { $_ ne "." and $_ ne ".." } readdir $dh; }; my $x = LEFT; my $y = TOP; for (@font_name) { if($y > HEIGHT) { $x += COL_WIDTH; $y = TOP; } my $ttf = File::Spec->catfile($fontDir, $_); $im->stringTTF($black, $tff, 12, 0, $x, $y, $_) or die "Failed trying to draw $_: $!\n"; $y += LINE_HEIGHT; } open my $fh, ">", "fonts.png" or die "Couldn't open fonts.png: $!\n"; binmode $fh; print $fh $im->png;