#!/usr/bin/perl =pod =head1 NAME showglyphs - create a F file that shows all glyphs in a font =head1 SYNOPSIS showglyphs I =head1 DESCRIPTION This program creates a F file that shows all glyphs in a given font. =head1 FILES =over 4 =item I This can be any Type 1 or TrueType font; OpenType fonts are not (yet?) supported. =back =head1 RESTRICTIONS =over 4 =item B<-> B only works on Unix/Linux systems. =item B<-> B needs a working, TDS-compliant Tex installation =back =head1 SEE ALSO F, F, F, F, F, F, F. =head1 AUTHOR Marc Penninga =head1 HISTORY =over 12 =item I<2005-04-28> First version =item I<2005-04-29> A few bugfixes; B now works with glyphnames containing underscores =item I<2005-05-24> Another bugfix =item I<2005-07-29> A few updates to the documentation =back =cut use integer; use warnings; no warnings qw(uninitialized); $0 =~ s!.*/!!g; die "Usage: $0 fontfile\n" if @ARGV != 1; system "mkdir -p ./showglyphs/"; system "cp $ARGV[0] ./showglyphs/"; chdir "./showglyphs"; system "font2afm $ARGV[0]"; $ARGV[0] =~ /([\w-]+)\./ and $fontname = $1; open AFM, "<${fontname}.afm" or die "Error: can't open `${fontname}.afm' - $!\n"; { local $/; $_ = ; } (/StartCharMetrics (\d+)/m and $num_glyphs = $1) or $num_glyphs = 255; @vec = (".notdef") x (($num_glyphs / 256 + 1) * 256); for (/(WX.*?$)/gm) {/N\s+([\w.]+)/ and $vec[$i++] = $1} system "cp `locate pdftex.map` ."; open TEX, ">tmp.tex" or die "Error: can't create `tmp.tex' - $!\n"; print TEX <$filename.enc" or die "Error: can't create `$filename.enc' - $!\n"; print ENC "%\n% Created ", scalar localtime, " by $0 from `${fontname}.afm'\n"; print ENC "%\n/", $filename, " [\n"; for ($j = 0; $j < 256; $j += 16) { printf ENC "%% 0x%04x\n", $j; for ($k = 0; $k < 16; $k += 4) { print ENC "\t"; for ($l = 0; $l < 4; $l++) { print ENC "/$vec[$i * 256 + $j + $k + $l] "; } print ENC "\n"; } } print ENC "] def\n"; close ENC; system "afm2afm -e '${filename}.enc' -o '${filename}.afm' " . "'${fontname}.afm' >>./pdftex.map"; system "afm2tfm '${fontname}.afm' -T '${filename}.enc' '${filename}.tfm'" . ">/dev/null"; for (@vec[256 * $i..256*($i+1)]) {s/(?= $num_glyphs; } } print TEX "\n\\end{document}\n"; close TEX; system "pdflatex tmp >/dev/null"; chdir "../"; system "mv showglyphs/tmp.pdf './${fontname}.pdf'"; system "/bin/rm -r ./showglyphs/"; __END__