It seems Imager::Font has some memory leak. On my system, I can only create about 1080 fonts at a time. That's why I use this with perl mkhtml >> index.html, and start it over 6 times. My ttf library has >5000 fonts.
#!/usr/bin/perl -w use strict; use Font::TTF::Font; use Imager qw(:handy); my $b = NC(0,0,0); my $w = NC(255, 255, 255); my $s ="The quick brown fox jumps over the lazy dog. 0123456789 {[()]} + @%&*?!"; my $e = 0; opendir D, '.'; while (defined(my $f = readdir D)) { next if $f !~ /ttf$/i; next if -e "$f.jpg"; print STDERR "$f\n"; my $n = Font::TTF::Font->open($f) || $f; $n = $n->{name} || $f if ref $n; $n = $n->read->find_name(4) || $f if ref $n; my $F = NF(file => $f, aa => 1) or $e++,print(STDERR $Imager::ERRS +TR),next; my @b = $F->bounding_box(string => $s); my ($x, $y) = ($b[2] - $b[0], $b[3] - $b[1]); my $i = Imager->new(xsize => $x, ysize => $y) or next; $i->box(filled => 1, color => $w); $i->string(font => $F, string => $s, x => $b[0], y => $b[3], color + => $b); $i->write(file => "$f.jpg"); print qq{$f - $n<br><img src="$f.jpg" alt="$f" width=$x height=$y> +<hr>\n}; } print STDERR "Failed: $e\n"
In reply to TrueType font gallery by Juerd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |