| Font HOWTO | ||
|---|---|---|
| <<< Previous | Next >>> | |
To make fonts available to ghostscript, it suffices to tell ghostscript where the files corresponding to a given font are located. The file that needs to be edited is /usr/share/ghostscript/version/FONTMAP.GS.For most people the reason you need to do this is because ghostscript complains about missing fonts and you probable cannot print successfully because of it.
Adding Type 1 fonts is straightforward. Make sure that the new fonts are in the ghostscript search path. It's a good idea to add all the fonts from the gs-fonts packages to the same directory. Type
gs -h |
Now run type1inst on the directory containing the fonts. type1inst will output a file called FONTMAP. Append this file to the ghostscriptFONTMAP.GS file by adding the text from the FONTMAP file you created with type1inst to the bottom of it. type1inst will also create a file called fonts.dir. You can leave this file as is.
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 |
#!/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;
} |
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 |
Once you've made fonts available to ghostscript, you can preview them. Do this by running the ghostscript interpreter on the file prfont.ps in your ghostscript installation, and after you start it, type: /Fontname DoFont at the ghostscript font ( where FontName is the ghostscript name of the font you wish to preview ). There are several other ways you can invoke gs. For example, if you want to create a PostScript file that you can look at in a nicer PostScript viewer such as gv, you can use gs -sDEVICE=pswrite -sOutputFile=somefile.ps prfont.ps Having done this, you can also print your output file.
| <<< Previous | Home | Next >>> |
| Making Fonts Available To X | True Type to Type 1 Conversion |