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"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: TrueType font gallery
by Louis_Wu (Chaplain) on Nov 09, 2002 at 19:44 UTC | |
by Juerd (Abbot) on Nov 09, 2002 at 22:27 UTC | |
by Louis_Wu (Chaplain) on Nov 09, 2002 at 22:35 UTC | |
by Juerd (Abbot) on Nov 11, 2002 at 01:33 UTC | |
by dws (Chancellor) on Nov 11, 2002 at 03:44 UTC | |
by Louis_Wu (Chaplain) on Nov 11, 2002 at 08:42 UTC | |
|
Re: TrueType font gallery
by december (Pilgrim) on Jun 04, 2003 at 17:48 UTC | |
by basje (Beadle) on Aug 09, 2005 at 20:43 UTC | |
by Juerd (Abbot) on Jun 04, 2003 at 17:54 UTC | |
by december (Pilgrim) on Jun 04, 2003 at 18:12 UTC | |
by Juerd (Abbot) on Jun 04, 2003 at 18:46 UTC | |
|
Re: TrueType font gallery
by naChoZ (Curate) on Jun 04, 2003 at 18:20 UTC | |
by december (Pilgrim) on Jun 04, 2003 at 19:38 UTC | |
by naChoZ (Curate) on Jun 04, 2003 at 19:54 UTC |