in reply to Draw Font Outline

Not really a Perl solution, but maybe it helps...  Also, this is limited to PostScript fonts (well, not strictly, but with other font types, things would get much more involved).

The real work is being done by the PostScript interpreter (gs in this case). Perl is just writing the PS commands to a temp file and then running the PS interpreter (which could of course be done equally well with a simple shell script — but as this is a Perl forum ... :)

The example would produce a 1000x500 pixel PNG file showing the word "Perl" in big letters being rendered in a blue dotted outline.

If you want to use any non-standard PS fonts, you have to include the respective .pfa or .pfb font files at the beginning of the PS code (where indicated). If you don't want PNG output, you can simply choose a different driver and specify it via -sDEVICE=... ("gs -h" for a list of available devices).

#!/usr/bin/perl my $tmpfile = "demo.ps"; my $outfile = "demo.png"; open my $ps, ">", $tmpfile or die "Cannot create temp file '$tmpfile': + $!"; print $ps <<'EOF'; %!PS % (include any non-standard fonts here...) /Times-Roman findfont 300 scalefont setfont 10 10 moveto % position (Perl) true charpath % charpath makes outline 5 setlinewidth 1 setlinejoin 1 setlinecap [.1 6] 0 setdash % dotted line 0 0 0.5 setrgbcolor % in dark blue stroke showpage EOF close $ps; system "gs -q -dBATCH -dNOPAUSE -sDEVICE=pngalpha -r140 -g1000x500 -sO +utputFile=$outfile $tmpfile";

(For this to work, you of course need to have GhostScript (gs) installed.)