old-www/HOWTO/TT-Debian-4.html

158 lines
4.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>TrueType Fonts in Debian mini-HOWTO: Printing (ghostscript)</TITLE>
<LINK HREF="TT-Debian-5.html" REL=next>
<LINK HREF="TT-Debian-3.html" REL=previous>
<LINK HREF="TT-Debian.html#toc4" REL=contents>
</HEAD>
<BODY>
<A HREF="TT-Debian-5.html">Next</A>
<A HREF="TT-Debian-3.html">Previous</A>
<A HREF="TT-Debian.html#toc4">Contents</A>
<HR>
<H2><A NAME="s4">4. Printing (<CODE>ghostscript</CODE>)</A></H2>
<P>Starting with version 4, <CODE>ghostscript</CODE> has supported TrueType
fonts as a compile-time option. Two Debian packages provide <CODE>ghostscript</CODE>:
<UL>
<LI><CODE>main/binary-*/text/gs_*.deb</CODE> is DFSG-compliant version 5.10,</LI>
<LI><CODE>non-free/binary-*/gs-aladdin_*.deb</CODE> is non-DFSG-compliant
version 5.50. </LI>
</UL>
Both versions support TrueType fonts.
<P>
<H2><A NAME="ss4.1">4.1 Configuring <CODE>Ghostscript</CODE> to use TrueType fonts</A>
</H2>
<P>If you have a working <CODE>xfstt</CODE> server, it is easy to configure
<CODE>ghostscript</CODE> to use TrueType fonts. We simply execute the
following command:
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
# xfstt --gslist --sync >> /etc/gs.Fontmap
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>In practice, I've found it beneficial to make several small changes
to the font definitions generated by <CODE>xfstt</CODE>. First, if a font name
does not contain any spaces, I change the name to the usual notation.
If a font name does contain spaces, I replace all spaces with dashes
and the original name is added as an alias to the new name.
<P>Finally, I prepend <CODE>TTF-</CODE> (or <CODE>MS-</CODE>) to all font names to
minimize problems caused by a TrueType font having an identical
name to an preexisting font.
<P>Thus
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
(Arial) (/usr/share/fonts/truetype/arial.ttf) ;
(Arial Bold Italic) (/usr/share/fonts/truetype/arialbi.ttf) ;
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>becomes
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
/MS-Arial (/usr/share/fonts/truetype/arial.ttf) ;
/MS-Arial-Bold-Italic (/usr/share/fonts/truetype/arialbi.ttf) ;
(Arial Bold Italic) /MS-Arial-Bold-Italic ;
/Arial /MS-Arial ;
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>The aliases ensure that <CODE>ghostscript</CODE> and <CODE>xfstt</CODE> can still
specify the same font by a common name.
<P>Much more significantly, with the change in the font names it's possible
to instruct <CODE>ghostscript</CODE> to use TrueType fonts instead of the
standard fonts. The documentation claims that this is also possible with
parenthetical notation, but I could not get it to work.
<P>For instance, we can instruct <CODE>ghostscript</CODE> to replace Helvetica fonts
with Microsoft's free Arial fonts by appending the following lines to the
<CODE>/etc/gs.Fontmap</CODE> file:
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
/Helvetica /MS-Arial ;
/Helvetica-Oblique /MS-Arial-Italic ;
/Helvetica-Bold /MS-Arial-Bold ;
/Helvetica-BoldOblique /MS-Arial-Bold-Italic ;
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>Similar aliases can be defined for the other standard fonts.
These aliases would be most useful on <CODE>samba</CODE> printers serving
Windows clients.
<P>
<H2><A NAME="ss4.2">4.2 Printing TrueType font specimens</A>
</H2>
<P>The best way to verify that <CODE>ghostscript</CODE> is properly configured to use
TrueType fonts is to print font specimen pages. Assuming that you're
running <CODE>ghostscript</CODE> 5.50 and that it is your default print queue,
you can print all TrueType fonts with the following command:
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
# xfstt --gslist --sync | printfont
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>where <CODE>printfont</CODE> is the following shell script
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
#!/bin/sh
set -e
IFS= ')'
while read fontname rest
do
cat &lt;&lt; EOM | lpr
%!PS
(/usr/lib/ghostscript/5.50/prfont.ps) run
$fontname) DoFont
EOM
done
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>If you wish to print only a few fonts, the following script will be
easier to use:
<P>
<BLOCKQUOTE><CODE>
<HR>
<PRE>
#!/bin/sh
set -e
while read -p "Font name, or ^D to exit: " fontname
do
cat &lt;&lt; EOM | lpr
%!PS
(/usr/lib/ghostscript/5.50/prfont.ps) run
$fontname DoFont
EOM
done
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>
<HR>
<A HREF="TT-Debian-5.html">Next</A>
<A HREF="TT-Debian-3.html">Previous</A>
<A HREF="TT-Debian.html#toc4">Contents</A>
</BODY>
</HTML>