Adding truetype fonts is a little trickier, because we have to get the
name of the TrueType font. One way (brute force, alas) to do this is using
the ttf2pt1 TrueType to Type 1 converter, and grabbing the font
name from the afm ( there's got to be a more efficient way !
but this works, ugly as it is ). You do it like this:
ttf2pt1 -A fontname - 2 > /dev/null |grep FontName |
Then you add an entry to the ghostscript
Fontmap file
in the correct format, eg
some-font (/usr/share/fonts/subdirectory/somefont.pbf);
Well, that works fine, but try doing it with 500 or so fonts.
This is the kind of thing that calls for a short perlscript:
#!/usr/bin/perl
# ttfontmap -- generate fontmap file for TrueType fonts
my $directory=shift || print STDERR "Usage: ttfontmap {directory}\n";
$directory=~s/\/$//;
for my $fontname ( glob ( "$directory/*.ttf" ) )
{
open ( R, "sh -c \"ttf2pt1 -A $fontname - 2>/dev/null\" |" );
while ( <R> )
{
if ( $_ =~ /^FontName/ )
{
s/^FontName\s*//;
chomp;
print "/" . $_ . " ($fontname);\n" ;
}
}
close R;
} |
You can
download this script To set this script up, all you need to do is cut and paste it into
a file called ttfontmap, and place the file somewhere
in your PATH ( such as /usr/bin ).
You run this script like this:
ttfontmap directory > output_file |
where
directory is the directory containing the
fonts. You are left with the file
output_file which you can append
to your ghostscript fontmap. Note: some will observe that you could
just use
ttfontmap directory >> /usr/share/ghostscript/version/Fontmap
However, I advise against this ( what would happen if you typed ``>'' instead of
``>>''
? )