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"
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|