2013-01-30 20:12:36 +01:00
<?xml version="1.0" encoding="iso-8859-1"?>
2013-11-07 16:39:28 +01:00
< !DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook XML V5.0-Based Extension//EN"
2013-11-13 08:52:45 +01:00
"http://www.FreeBSD.org/XML/share/xml/freebsd50.dtd">
2001-10-16 13:53:01 +02:00
<!-- $FreeBSD$ -->
1997-02-15 19:02:20 +01:00
<!-- The FreeBSD Documentation Project -->
<!-- Recently, I wanted to figure out how to use some additional fonts that
I had accumulated. I finally figured out *how to do it* from the various
2002-07-11 21:08:31 +02:00
manual pages and documentation. Since it might be of use to other users,
1997-02-15 19:02:20 +01:00
and I didn't see any reference to this topic in the FAQ or handbook, I
thought I'd try my hand at a simple cookbook tutorial addressing the
use of fonts. I have included my unanswered questions at the end of
the document.
Anyway, here's what I put together. This is my present understanding of
fonts and how to use them with FreeBSD. I am sure that there are errors or
misunderstandings, but it contains enough valid information to allow the
use of additional fonts with Ghostscript, X11 and Groff. This is my first
attempt to write anything along the lines of a tutorial/FAQ, so I am sure
it is pretty raw. There are probably better ways to do some of this stuff,
and I would welcome being corrected.
-->
2000-06-20 13:30:11 +02:00
<!-- The section "Setting a virtual console to 80x60 line mode" was
updated to reflect changes in FreeBSD system configuration
2001-10-23 23:31:20 +02:00
files by Mark Ovens <mark @ u k u g . u k . F r e e B S D . o r g > 27/5/00
2000-06-20 13:30:11 +02:00
-->
2013-11-07 16:39:28 +01:00
<article xmlns= "http://docbook.org/ns/docbook" xmlns:xlink= "http://www.w3.org/1999/xlink" version= "5.0" xml:lang= "en" >
<info > <title > Fonts and FreeBSD</title> <subtitle > A Tutorial</subtitle>
2000-06-20 13:30:11 +02:00
2013-11-07 16:39:28 +01:00
1997-02-15 19:02:20 +01:00
1999-10-10 20:35:50 +02:00
<authorgroup >
2013-11-07 16:39:28 +01:00
<author > <personname > <firstname > Dave</firstname> <surname > Bodenstab</surname> </personname> <affiliation >
1999-10-10 20:35:50 +02:00
<address >
<email > imdave@synet.net</email>
</address>
2013-11-07 16:39:28 +01:00
</affiliation> </author>
1999-10-10 20:35:50 +02:00
</authorgroup>
1997-02-15 19:02:20 +01:00
1999-10-10 20:35:50 +02:00
<pubdate > Wed Aug 7, 1996</pubdate>
1997-02-15 19:02:20 +01:00
2012-06-21 18:01:00 +02:00
<releaseinfo > $FreeBSD$</releaseinfo>
2013-11-07 16:39:28 +01:00
<legalnotice xml:id= "trademarks" role= "trademarks" >
2003-08-14 21:54:05 +02:00
&tm-attrib.freebsd;
&tm-attrib.adobe;
&tm-attrib.apple;
&tm-attrib.linux;
&tm-attrib.microsoft;
&tm-attrib.opengroup;
&tm-attrib.general;
</legalnotice>
1999-10-10 20:35:50 +02:00
<abstract >
<para > This document contains a description of the various font
files that may be used with FreeBSD and the syscons driver,
2005-04-23 00:46:19 +02:00
<application > X11</application> , <application > Ghostscript</application>
and <application > Groff</application> . Cookbook examples are provided
1999-10-10 20:35:50 +02:00
for switching the syscons display to 80x60 mode, and for using
type 1 fonts with the above application programs.</para>
</abstract>
2013-11-07 16:39:28 +01:00
</info>
1997-02-15 19:02:20 +01:00
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "intro" >
1999-10-10 20:35:50 +02:00
<title > Introduction</title>
<para > There are many sources of fonts available, and one might ask
how they might be used with FreeBSD. The answer can be found by
carefully searching the documentation for the component that one
would like to use. This is very time consuming, so this
tutorial is an attempt to provide a shortcut for others who
might be interested.</para>
</sect1>
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "terminology" >
1999-10-10 20:35:50 +02:00
<title > Basic terminology</title>
<para > There are many different font formats and associated font
file suffixes. A few that will be addressed here are:</para>
<variablelist >
<varlistentry >
2000-07-26 20:24:50 +02:00
<term > <filename > .pfa</filename> , <filename > .pfb</filename> </term>
1999-10-10 20:35:50 +02:00
<listitem >
2003-08-14 21:54:05 +02:00
<para > &postscript; type 1 fonts. The
1999-10-10 20:35:50 +02:00
<filename > .pfa</filename> is the
<emphasis > A</emphasis> scii form and
<filename > .pfb</filename> the <emphasis > B</emphasis> inary
form.</para>
</listitem>
</varlistentry>
<varlistentry >
2000-07-26 20:24:50 +02:00
<term > <filename > .afm</filename> </term>
1999-10-10 20:35:50 +02:00
<listitem >
<para > The font metrics associated with a type 1 font.</para>
</listitem>
</varlistentry>
<varlistentry >
2000-07-26 20:24:50 +02:00
<term > <filename > .pfm</filename> </term>
1999-10-10 20:35:50 +02:00
<listitem >
<para > The printer font metrics associated with a type 1
font.</para>
</listitem>
</varlistentry>
<varlistentry >
2000-07-26 20:24:50 +02:00
<term > <filename > .ttf</filename> </term>
1999-10-10 20:35:50 +02:00
<listitem >
2003-08-14 21:54:05 +02:00
<para > A &truetype; font</para>
1999-10-10 20:35:50 +02:00
</listitem>
</varlistentry>
<varlistentry >
2000-07-26 20:24:50 +02:00
<term > <filename > .fot</filename> </term>
1999-10-10 20:35:50 +02:00
<listitem >
<para > An indirect reference to a TrueType font (not an
actual font)</para>
</listitem>
</varlistentry>
<varlistentry >
2000-07-26 20:24:50 +02:00
<term > <filename > .fon</filename> , <filename > .fnt</filename> </term>
1999-10-10 20:35:50 +02:00
<listitem >
<para > Bitmapped screen fonts</para>
</listitem>
</varlistentry>
</variablelist>
2003-08-14 21:54:05 +02:00
<para > The <filename > .fot</filename> file is used by &windows; as
sort of a symbolic link to the actual &truetype; font
1999-10-10 20:35:50 +02:00
(<filename > .ttf</filename> ) file. The <filename > .fon</filename>
font files are also used by Windows. I know of no way to use
this font format with FreeBSD.</para>
</sect1>
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "font-formats" >
1999-10-10 20:35:50 +02:00
<title > What font formats can I use?</title>
<para > Which font file format is useful depends on the application
being used. FreeBSD by itself uses no fonts. Application
programs and/or drivers may make use of the font files. Here is
a small cross reference of application/driver to the font type
suffixes:</para>
<variablelist >
<varlistentry >
<term > Driver</term>
<listitem >
<variablelist >
<varlistentry >
<term > syscons</term>
<listitem >
2000-07-26 20:24:50 +02:00
<para > <filename > .fnt</filename> </para>
1999-10-10 20:35:50 +02:00
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry >
<term > Application</term>
1997-02-15 19:02:20 +01:00
1999-10-10 20:35:50 +02:00
<listitem >
<variablelist >
<varlistentry >
2005-04-23 00:46:19 +02:00
<term > <application > Ghostscript</application> </term>
1999-10-10 20:35:50 +02:00
<listitem >
<para > <filename > .pfa</filename> ,
<filename > .pfb</filename> ,
<filename > .ttf</filename> </para>
</listitem>
</varlistentry>
<varlistentry >
2005-04-23 00:46:19 +02:00
<term > <application > X11</application> </term>
1999-10-10 20:35:50 +02:00
<listitem >
<para > <filename > .pfa</filename> ,
<filename > .pfb</filename> </para>
</listitem>
</varlistentry>
<varlistentry >
2005-04-23 00:46:19 +02:00
<term > <application > Groff</application> </term>
1999-10-10 20:35:50 +02:00
<listitem >
<para > <filename > .pfa</filename> ,
<filename > .afm</filename> </para>
</listitem>
</varlistentry>
<varlistentry >
2005-04-23 00:46:19 +02:00
<term > <application > Povray</application> </term>
1999-10-10 20:35:50 +02:00
<listitem >
<para > <filename > .ttf</filename> </para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
</variablelist>
1997-02-15 19:02:20 +01:00
1999-10-10 20:35:50 +02:00
<para > The <filename > .fnt</filename> suffix is used quite
frequently. I suspect that whenever someone wanted to create a
specialized font file for their application, more often than not
they chose this suffix. Therefore, it is likely that files with
this suffix are not all the same format; specifically, the
<filename > .fnt</filename> files used by syscons under FreeBSD
may not be the same format as a <filename > .fnt</filename> file
2003-08-14 21:54:05 +02:00
one encounters in the &ms-dos; /&windows; environment. I have not
1999-10-10 20:35:50 +02:00
made any attempt at using other <filename > .fnt</filename> files
other than those provided with FreeBSD.</para>
</sect1>
1997-02-15 19:02:20 +01:00
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "virtual-console" >
1999-10-10 20:35:50 +02:00
<title > Setting a virtual console to 80x60 line mode</title>
1997-02-15 19:02:20 +01:00
2000-06-20 13:30:11 +02:00
<para > First, an 8x8 font must be loaded. To do this,
<filename > /etc/rc.conf</filename> should contain the
line (change the font name to an appropriate one for
your locale):</para>
1997-02-15 19:02:20 +01:00
1999-10-10 20:35:50 +02:00
<informalexample >
2001-04-09 02:33:58 +02:00
<programlisting > font8x8="iso-8x8" # font 8x8 from /usr/share/syscons/fonts/* (or NO).</programlisting>
1999-10-10 20:35:50 +02:00
</informalexample>
1997-02-15 19:02:20 +01:00
1999-10-10 20:35:50 +02:00
<para > The command to actually switch the mode is
2001-03-11 08:48:57 +01:00
&man.vidcontrol.1; :</para>
1997-02-15 19:02:20 +01:00
1999-10-10 20:35:50 +02:00
<informalexample >
2001-07-06 15:03:06 +02:00
<screen > &prompt.user; <userinput > vidcontrol VGA_80x60</userinput> </screen>
1999-10-10 20:35:50 +02:00
</informalexample>
1997-02-15 19:02:20 +01:00
2001-07-10 16:00:17 +02:00
<para > Various screen-oriented programs, such as &man.vi.1; , must
2000-06-20 13:30:11 +02:00
be able to determine the current screen dimensions. As this is
achieved this through <command > ioctl</command> calls to the console
2001-03-11 08:48:57 +01:00
driver (such as &man.syscons.4; ) they will correctly determine the new
2000-06-20 13:30:11 +02:00
screen dimensions.</para>
1997-02-15 19:02:20 +01:00
1999-10-10 20:35:50 +02:00
<para > To make this more seamless, one can embed these commands in
the startup scripts so it takes place when the system boots.
2000-06-20 13:30:11 +02:00
To do this is add this line to <filename > /etc/rc.conf</filename>
</para>
1999-10-10 20:35:50 +02:00
<informalexample >
2000-06-20 13:30:11 +02:00
<programlisting > allscreens_flags="VGA_80x60" # Set this vidcontrol mode for all virtual screens
1999-10-10 20:35:50 +02:00
</programlisting>
</informalexample>
2000-06-20 13:30:11 +02:00
<para > References: &man.rc.conf.5; , &man.vidcontrol.1; .</para>
1999-10-10 20:35:50 +02:00
</sect1>
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "type1-fonts-x11" >
2005-04-23 00:46:19 +02:00
<title > Using type 1 fonts with <application > X11</application> </title>
1999-10-10 20:35:50 +02:00
2005-04-23 00:46:19 +02:00
<para > <application > X11</application> can use either the <filename > .pfa</filename> or the
<filename > .pfb</filename> format fonts. The <application > X11</application> fonts are
1999-10-10 20:35:50 +02:00
located in various subdirectories under
<filename > /usr/X11R6/lib/X11/fonts</filename> . Each font file
2005-04-23 00:46:19 +02:00
is cross referenced to its <application > X11</application> name by the contents of the
1999-10-10 20:35:50 +02:00
<filename > fonts.dir</filename> file in each directory.</para>
2000-07-26 20:24:50 +02:00
<para > There is already a directory named <filename > Type1</filename> . The
1999-10-10 20:35:50 +02:00
most straight forward way to add a new font is to put it into
this directory. A better way is to keep all new fonts in a
separate directory and use a symbolic link to the additional
font. This allows one to more easily keep track of ones fonts
without confusing them with the fonts that were originally
provided. For example:</para>
<informalexample >
2001-03-11 08:48:57 +01:00
<screen > <lineannotation > Create a directory to contain the font files</lineannotation>
&prompt.user; <userinput > mkdir -p /usr/local/share/fonts/type1</userinput>
&prompt.user; <userinput > cd /usr/local/share/fonts/type1</userinput>
<lineannotation > Place the .pfa, .pfb and .afm files here</lineannotation>
<lineannotation > One might want to keep readme files, and other documentation</lineannotation>
<lineannotation > for the fonts here also</lineannotation>
&prompt.user; <userinput > cp /cdrom/fonts/atm/showboat/showboat.pfb .</userinput>
&prompt.user; <userinput > cp /cdrom/fonts/atm/showboat/showboat.afm .</userinput>
<lineannotation > Maintain an index to cross reference the fonts</lineannotation>
2001-07-06 15:03:06 +02:00
&prompt.user; <userinput > echo showboat - InfoMagic CICA, Dec 1994, /fonts/atm/showboat > > INDEX</userinput> </screen>
1999-10-10 20:35:50 +02:00
</informalexample>
2005-04-23 00:46:19 +02:00
<para > Now, to use a new font with <application > X11</application> , one must make the font file
available and update the font name files. The <application > X11</application> font names
1999-10-10 20:35:50 +02:00
look like:</para>
<informalexample >
<screen > -bitstream-charter-medium-r-normal-xxx-0-0-0-0-p-0-iso8859-1
| | | | | | | | | | | | \ \
1997-02-15 19:02:20 +01:00
| | | | | \ \ \ \ \ \ \ +----+- character set
| | | | \ \ \ \ \ \ \ +- average width
| | | | \ \ \ \ \ \ +- spacing
| | | \ \ \ \ \ \ +- vertical res.
| | | \ \ \ \ \ +- horizontal res.
| | | \ \ \ \ +- points
| | | \ \ \ +- pixels
| | | \ \ \
2001-07-06 15:03:06 +02:00
foundry family weight slant width additional style</screen>
1999-10-10 20:35:50 +02:00
</informalexample>
<para > A new name needs to be created for each new font. If you
have some information from the documentation that accompanied
the font, then it could serve as the basis for creating the
name. If there is no information, then you can get some idea by
using &man.strings.1; on the font file. For example:</para>
<informalexample >
2001-03-11 08:48:57 +01:00
<screen > &prompt.user; <userinput > strings showboat.pfb | more</userinput>
1997-02-15 19:02:20 +01:00
%!FontType1-1.0: Showboat 001.001
%%CreationDate: 1/15/91 5:16:03 PM
%%VMusage: 1024 45747
% Generated by Fontographer 3.1
% Showboat
1991 by David Rakowski. Alle Rechte Vorbehalten.
FontDirectory/Showboat known{/Showboat findfont dup/UniqueID known{dup
/UniqueID get 4962377 eq exch/FontType get 1 eq and}{pop false}ifelse
{save true}{false}ifelse}{false}ifelse
12 dict begin
/FontInfo 9 dict dup begin
/version (001.001) readonly def
/FullName (Showboat) readonly def
/FamilyName (Showboat) readonly def
/Weight (Medium) readonly def
/ItalicAngle 0 def
/isFixedPitch false def
/UnderlinePosition -106 def
/UnderlineThickness 16 def
/Notice (Showboat
1991 by David Rakowski. Alle Rechte Vorbehalten.) readonly def
end readonly def
/FontName /Showboat def
2001-07-06 15:03:06 +02:00
--stdin--</screen>
1999-10-10 20:35:50 +02:00
</informalexample>
<para > Using this information, a possible name might be:</para>
<informalexample >
2001-07-06 15:03:06 +02:00
<screen > -type1-Showboat-medium-r-normal-decorative-0-0-0-0-p-0-iso8859-1</screen>
1999-10-10 20:35:50 +02:00
</informalexample>
<para > The components of our name are:</para>
<variablelist >
<varlistentry >
<term > Foundry</term>
<listitem >
<para > Lets just name all the new fonts
2000-07-26 20:24:50 +02:00
<literal > type1</literal> .</para>
1999-10-10 20:35:50 +02:00
</listitem>
</varlistentry>
<varlistentry >
<term > Family</term>
<listitem >
<para > The name of the font.</para>
</listitem>
</varlistentry>
<varlistentry >
<term > Weight</term>
<listitem >
<para > Normal, bold, medium, semibold, etc. From the
2001-03-11 08:48:57 +01:00
&man.strings.1;
1999-10-10 20:35:50 +02:00
output above, it appears that this font has a weight of
<emphasis > medium</emphasis> .</para>
</listitem>
</varlistentry>
<varlistentry >
<term > Slant</term>
<listitem >
2013-11-07 16:39:28 +01:00
<para > <emphasis remap= "bf" > r</emphasis> oman, <emphasis remap= "bf" > i</emphasis> talic, <emphasis remap= "bf" > o</emphasis> blique, etc. Since the
1999-10-10 20:35:50 +02:00
<emphasis > ItalicAngle</emphasis> is zero,
<emphasis > roman</emphasis> will be used.</para>
</listitem>
</varlistentry>
<varlistentry >
<term > Width</term>
<listitem >
<para > Normal, wide, condensed, extended, etc. Until it can
be examined, the assumption will be
<emphasis > normal</emphasis> .</para>
</listitem>
</varlistentry>
<varlistentry >
<term > Additional style</term>
<listitem >
<para > Usually omitted, but this will indicate that the font
contains decorative capital letters.</para>
</listitem>
</varlistentry>
<varlistentry >
<term > Spacing</term>
<listitem >
<para > proportional or monospaced.
<emphasis > Proportional</emphasis> is used since
<emphasis > isFixedPitch</emphasis> is false.</para>
</listitem>
</varlistentry>
</variablelist>
<para > All of these names are arbitrary, but one should strive to
be compatible with the existing conventions. A font is
2005-04-23 00:46:19 +02:00
referenced by name with possible wild cards by an <application > X11</application> program,
1999-10-10 20:35:50 +02:00
so the name chosen should make some sense. One might begin by
simply using
<informalexample >
<screen > … -normal-r-normal-… -p-…
</screen>
</informalexample>
as the name, and then use
2001-03-11 08:48:57 +01:00
&man.xfontsel.1;
to examine it and adjust the name based on the appearance of the
1999-10-10 20:35:50 +02:00
font.</para>
<para > So, to complete our example:</para>
<informalexample >
2001-03-11 08:48:57 +01:00
<screen > <lineannotation > Make the font accessible to X11</lineannotation>
&prompt.user; <userinput > cd /usr/X11R6/lib/X11/fonts/Type1</userinput>
&prompt.user; <userinput > ln -s /usr/local/share/fonts/type1/showboat.pfb .</userinput>
1997-02-15 19:02:20 +01:00
<lineannotation > Edit fonts.dir and fonts.scale, adding the line describing the font
2001-03-11 08:48:57 +01:00
and incrementing the number of fonts which is found on the first line.</lineannotation>
&prompt.user; <userinput > ex fonts.dir
1997-02-15 19:02:20 +01:00
:1p
25
:1c
26
.
:$a
showboat.pfb -type1-showboat-medium-r-normal-decorative-0-0-0-0-p-0-iso8859-1
.
2001-03-11 08:48:57 +01:00
:wq</userinput>
1997-02-15 19:02:20 +01:00
2013-11-07 16:39:28 +01:00
<lineannotation > fonts.scale seems to be identical to fonts.dir… </lineannotation>
2001-03-11 08:48:57 +01:00
&prompt.user; <userinput > cp fonts.dir fonts.scale</userinput>
1997-02-15 19:02:20 +01:00
2001-03-11 08:48:57 +01:00
<lineannotation > Tell X11 that things have changed</lineannotation>
&prompt.user; <userinput > xset fp rehash</userinput>
1997-02-15 19:02:20 +01:00
2001-03-11 08:48:57 +01:00
<lineannotation > Examine the new font</lineannotation>
2001-07-06 15:03:06 +02:00
&prompt.user; <userinput > xfontsel -pattern -type1-*</userinput> </screen>
1999-10-10 20:35:50 +02:00
</informalexample>
<para > References: &man.xfontsel.1; , &man.xset.1; , <citetitle > The X
2013-11-07 16:39:28 +01:00
Windows System in a Nutshell</citetitle> , <link xlink:href= "http://www.ora.com/" > O'Reilly &
Associates</link> .</para>
1999-10-10 20:35:50 +02:00
</sect1>
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "type1-fonts-ghostscript" >
1999-10-10 20:35:50 +02:00
<title > Using type 1 fonts with Ghostscript</title>
2005-04-23 00:46:19 +02:00
<para > <application > Ghostscript</application> references a font via its <filename > Fontmap</filename>
file. This must be modified in a similar way to the <application > X11</application>
<filename > fonts.dir</filename> file. <application > Ghostscript</application> can use either
1999-10-10 20:35:50 +02:00
the <filename > .pfa</filename> or the <filename > .pfb</filename>
format fonts. Using the font from the previous example, here is
2005-04-23 00:46:19 +02:00
how to use it with <application > Ghostscript</application> :</para>
1999-10-10 20:35:50 +02:00
<informalexample >
2001-03-11 08:48:57 +01:00
<screen > <lineannotation > Put the font in Ghostscript's font directory</lineannotation>
&prompt.user; <userinput > cd /usr/local/share/ghostscript/fonts</userinput>
&prompt.user; <userinput > ln -s /usr/local/share/fonts/type1/showboat.pfb .</userinput>
1997-02-15 19:02:20 +01:00
2001-03-11 08:48:57 +01:00
<lineannotation > Edit Fontmap so Ghostscript knows about the font</lineannotation>
&prompt.user; <userinput > cd /usr/local/share/ghostscript/4.01</userinput>
&prompt.user; <userinput > ex Fontmap
1997-02-15 19:02:20 +01:00
:$a
/Showboat (showboat.pfb) ; % From CICA /fonts/atm/showboat
.
2001-03-11 08:48:57 +01:00
:wq</userinput>
1997-02-15 19:02:20 +01:00
2001-03-11 08:48:57 +01:00
<lineannotation > Use Ghostscript to examine the font</lineannotation>
&prompt.user; <userinput > gs prfont.ps</userinput>
1997-02-15 19:02:20 +01:00
Aladdin Ghostscript 4.01 (1996-7-10)
Copyright (C) 1996 Aladdin Enterprises, Menlo Park, CA. All rights
reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading Times-Roman font from /usr/local/share/ghostscript/fonts/tir_____.pfb...
/1899520 581354 1300084 13826 0 done.
2001-03-11 08:48:57 +01:00
GS> <userinput > Showboat DoFont</userinput>
1997-02-15 19:02:20 +01:00
Loading Showboat font from /usr/local/share/ghostscript/fonts/showboat.pfb...
1939688 565415 1300084 16901 0 done.
> > showpage, press < return> to continue< <
> > showpage, press < return> to continue< <
> > showpage, press < return> to continue< <
2001-07-06 15:03:06 +02:00
GS> <userinput > quit</userinput> </screen>
1999-10-10 20:35:50 +02:00
</informalexample>
<para > References: <filename > fonts.txt</filename> in the
2005-04-23 00:46:19 +02:00
<application > Ghostscript 4.01</application> distribution</para>
1999-10-10 20:35:50 +02:00
</sect1>
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "type1-fonts-groff" >
1999-10-10 20:35:50 +02:00
<title > Using type 1 fonts with Groff</title>
2005-04-23 00:46:19 +02:00
<para > Now that the new font can be used by both <application > X11</application> and
2012-08-21 21:16:02 +02:00
<application > Ghostscript</application> , how can one use the new font
2005-04-23 00:46:19 +02:00
with <application > groff</application> ? First of
2003-08-14 21:54:05 +02:00
all, since we are dealing with type 1 &postscript; fonts, the
2005-04-23 00:46:19 +02:00
<application > groff</application> device that is applicable is the <emphasis > ps</emphasis>
device. A font file must be created for each font that <application > groff</application>
can use. A <application > groff</application> font name is just a file in
1999-10-10 20:35:50 +02:00
<filename > /usr/share/groff_font/devps</filename> . With our
example, the font file could be
<filename > /usr/share/groff_font/devps/SHOWBOAT</filename> . The
2005-04-23 00:46:19 +02:00
file must be created using tools provided by <application > groff</application> .</para>
1999-10-10 20:35:50 +02:00
2000-07-26 20:24:50 +02:00
<para > The first tool is <command > afmtodit</command> . This is not
1999-10-10 20:35:50 +02:00
normally installed, so it must be retrieved from the source
distribution. I found I had to change the first line of the
file, so I did:</para>
<informalexample >
2001-03-11 08:48:57 +01:00
<screen > &prompt.user; <userinput > cp /usr/src/gnu/usr.bin/groff/afmtodit/afmtodit.pl /tmp</userinput>
&prompt.user; <userinput > ex /tmp/afmtodit.pl
1997-02-15 19:02:20 +01:00
:1c
#!/usr/bin/perl -P-
.
2001-07-06 15:03:06 +02:00
:wq</userinput> </screen>
1999-10-10 20:35:50 +02:00
</informalexample>
2005-04-23 00:46:19 +02:00
<para > This tool will create the <application > groff</application> font file from the metrics
1999-10-10 20:35:50 +02:00
file (<filename > .afm</filename> suffix.) Continuing with our
example:</para>
<informalexample >
2013-11-07 16:39:28 +01:00
<screen > <lineannotation > Many .afm files are in Mac format… ^M delimited lines
2013-06-20 16:50:47 +02:00
We need to convert them to &unix; style ^J delimited lines</lineannotation>
2001-03-11 08:48:57 +01:00
&prompt.user; <userinput > cd /tmp</userinput>
&prompt.user; <userinput > cat /usr/local/share/fonts/type1/showboat.afm |
tr '\015' '\012' > showboat.afm</userinput>
<lineannotation > Now create the groff font file</lineannotation>
&prompt.user; <userinput > cd /usr/share/groff_font/devps</userinput>
2001-07-06 15:03:06 +02:00
&prompt.user; <userinput > /tmp/afmtodit.pl -d DESC -e text.enc /tmp/showboat.afm generate/textmap SHOWBOAT</userinput> </screen>
1999-10-10 20:35:50 +02:00
</informalexample>
<para > The font can now be referenced with the name
SHOWBOAT.</para>
2005-04-23 00:46:19 +02:00
<para > If <application > Ghostscript</application> is used to drive the printers on the system,
then nothing more needs to be done. However, if true &postscript;
1999-10-10 20:35:50 +02:00
printers are used, then the font must be down loaded to the
printer in order for the font to be used (unless the printer
happens to have the showboat font built in or on an accessible
font disk.) The final step is to create a down loadable font.
2000-07-26 20:24:50 +02:00
The <command > pfbtops</command> tool is used to create the
1999-10-10 20:35:50 +02:00
<filename > .pfa</filename> format of the font, and the
2000-07-26 20:24:50 +02:00
<filename > download</filename> file is modified to reference the new
font. The <filename > download</filename> file must reference the
1999-10-10 20:35:50 +02:00
internal name of the font. This can easily be determined from
the groff font file as illustrated:</para>
<informalexample >
2013-11-07 16:39:28 +01:00
<screen > <lineannotation > Create the .pfa font file</lineannotation>
2001-07-06 15:03:06 +02:00
&prompt.user; <userinput > pfbtops /usr/local/share/fonts/type1/showboat.pfb > showboat.pfa</userinput> </screen>
1999-10-10 20:35:50 +02:00
</informalexample>
<para > Of course, if the <filename > .pfa</filename> file is already
available, just use a symbolic link to reference it.</para>
<informalexample >
2001-03-11 08:48:57 +01:00
<screen > <lineannotation > Get the internal font name</lineannotation>
&prompt.user; <userinput > fgrep internalname SHOWBOAT</userinput>
1997-02-15 19:02:20 +01:00
internalname Showboat
2001-03-11 08:48:57 +01:00
<lineannotation > Tell groff that the font must be down loaded</lineannotation>
&prompt.user; <userinput > ex download
1997-02-15 19:02:20 +01:00
:$a
Showboat showboat.pfa
.
2001-07-06 15:03:06 +02:00
:wq</userinput> </screen>
1999-10-10 20:35:50 +02:00
</informalexample>
<para > To test the font:</para>
<informalexample >
2001-03-11 08:48:57 +01:00
<screen > &prompt.user; <userinput > cd /tmp</userinput>
&prompt.user; <userinput > cat > example.t < < EOF
1997-02-15 19:02:20 +01:00
.sp 5
.ps 16
This is an example of the Showboat font:
.br
.ps 48
.vs (\n(.s+2)p
.sp
.ft SHOWBOAT
ABCDEFGHI
.br
JKLMNOPQR
.br
STUVWXYZ
.sp
.ps 16
.vs (\n(.s+2)p
.fp 5 SHOWBOAT
.ft R
To use it for the first letter of a paragraph, it will look like:
.sp 50p
\s(48\f5H\s0\fRere is the first sentence of a paragraph that uses the
showboat font as its first letter.
Additional vertical space must be used to allow room for the larger
letter.
2001-03-11 08:48:57 +01:00
EOF</userinput>
&prompt.user; <userinput > groff -Tps example.t > example.ps</userinput>
1997-02-15 19:02:20 +01:00
2001-03-11 08:48:57 +01:00
<lineannotation > To use ghostscript/ghostview</lineannotation>
&prompt.user; <userinput > ghostview example.ps</userinput>
1997-02-15 19:02:20 +01:00
2001-03-11 08:48:57 +01:00
<lineannotation > To print it</lineannotation>
2001-07-06 15:03:06 +02:00
&prompt.user; <userinput > lpr -Ppostscript example.ps</userinput> </screen>
1999-10-10 20:35:50 +02:00
</informalexample>
<para > References:
<filename > /usr/src/gnu/usr.bin/groff/afmtodit/afmtodit.man</filename> ,
&man.groff.font.5; , &man.groff.char.7; , &man.pfbtops.1; .</para>
</sect1>
1997-02-15 19:02:20 +01:00
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "convert-truetype" >
2003-08-14 21:54:05 +02:00
<title > Converting TrueType fonts to a groff/PostScript format for
1999-08-06 19:35:18 +02:00
groff</title>
<para > This potentially requires a bit of work, simply because it
depends on some utilities that are not installed as part of the
1999-10-10 20:35:50 +02:00
base system. They are:</para>
1999-08-06 19:35:18 +02:00
<variablelist >
<varlistentry >
<term > <command > ttf2pf</command> </term>
<listitem >
2003-08-14 21:54:05 +02:00
<para > TrueType to PostScript conversion utilities. This
1999-08-06 19:35:18 +02:00
allows conversion of a TrueType font to an ascii font
metric (<filename > .afm</filename> ) file.</para>
1999-10-10 20:35:50 +02:00
2013-11-07 16:39:28 +01:00
<para > Currently available at <uri xlink:href= "http://sunsite.icm.edu.pl/pub/GUST/contrib/BachoTeX98/ttf2pf/" > http://sunsite.icm.edu.pl/pub/GUST/contrib/BachoTeX98/ttf2pf/</uri> .
2003-08-14 21:54:05 +02:00
Note: These files are PostScript programs and must be
1999-08-06 19:35:18 +02:00
downloaded to disk by holding down the
1999-10-10 20:35:50 +02:00
<keycap > Shift</keycap> key when clicking on the link.
Otherwise, your browser may try to launch
1999-08-06 19:35:18 +02:00
<application > ghostview</application> to view them.</para>
<para > The files of interest are:</para>
<itemizedlist >
<listitem >
2000-07-26 20:24:50 +02:00
<para > <filename > GS_TTF.PS</filename> </para>
1999-08-06 19:35:18 +02:00
</listitem>
<listitem >
<para > <filename > PF2AFM.PS</filename> </para>
</listitem>
<listitem >
<para > <filename > ttf2pf.ps</filename> </para>
</listitem>
</itemizedlist>
<para > The funny upper/lower case is due to their being
intended also for DOS shells.
<filename > ttf2pf.ps</filename> makes use of the others as
1999-10-10 20:35:50 +02:00
upper case, so any renaming must be consistent with this.
(Actually, <filename > GS_TTF.PS</filename> and
1999-08-06 19:35:18 +02:00
<filename > PFS2AFM.PS</filename> are supposedly part of the
2005-04-23 00:46:19 +02:00
<application > Ghostscript</application> distribution, but it is just as easy to use
2001-10-16 13:53:01 +02:00
these as an isolated utility. FreeBSD does not seem to
1999-08-06 19:35:18 +02:00
include the latter.) You also may want to have these
installed to
<filename > /usr/local/share/groff_font/devps</filename> (?).</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <command > afmtodit</command> </term>
<listitem >
2005-04-23 00:46:19 +02:00
<para > Creates font files for use with <application > groff</application> from ascii font
1999-10-10 20:35:50 +02:00
metrics file. This usually resides in the directory,
1999-08-06 19:35:18 +02:00
<filename > /usr/src/contrib/groff/afmtodit</filename> , and
requires some work to get going.</para>
<note >
2001-10-16 13:53:01 +02:00
<para > If you are paranoid about working in the
1999-08-06 19:35:18 +02:00
<filename > /usr/src</filename> tree, simply copy the
contents of the above directory to a work
location.</para>
</note>
2001-10-16 13:53:01 +02:00
<para > In the work area, you will need to make the utility.
1999-10-10 20:35:50 +02:00
Just type:</para>
1999-08-06 19:35:18 +02:00
1999-10-10 20:35:50 +02:00
<screen > <prompt > #</prompt> <userinput > make -f Makefile.sub afmtodit</userinput>
1999-08-06 19:35:18 +02:00
</screen>
<para > You may also need to copy
<filename > /usr/contrib/groff/devps/generate/textmap</filename>
to
<filename > /usr/share/groff_font/devps/generate</filename>
2001-10-16 13:53:01 +02:00
if it does not already exist.</para>
1999-08-06 19:35:18 +02:00
</listitem>
</varlistentry>
</variablelist>
2001-10-16 13:53:01 +02:00
<para > Once all these utilities are in place, you are ready to
1999-08-06 19:35:18 +02:00
commence:</para>
<orderedlist >
<listitem >
<para > Create the <filename > .afm</filename> file by
typing:</para>
2014-04-29 23:08:25 +02:00
<screen > <prompt > %</prompt> <userinput > gs -dNODISPLAY -q -- ttf2pf.ps <replaceable > TTF_name</replaceable> <replaceable > PS_font_name</replaceable> <replaceable > AFM_name</replaceable> </userinput>
1999-08-06 19:35:18 +02:00
</screen>
<para > Where, <replaceable > TTF_name</replaceable> is your
TrueType font file, <replaceable > PS_font_name</replaceable>
is the file name for the <filename > .pfa</filename> file,
<replaceable > AFM_name</replaceable> is the name you wish for
the <filename > .afm</filename> file. If you do not specify
output file names for the <filename > .pfa</filename> or
<filename > .afm</filename> files, then default names will be
generated from the TrueType font file name.</para>
<para > This also produces a <filename > .pfa</filename> file, the
2003-08-14 21:54:05 +02:00
ascii PostScript font metrics file
2001-07-10 16:00:17 +02:00
(<filename > .pfb</filename> is for the binary form). This
2001-10-16 13:53:01 +02:00
will not be needed, but could (I think) be useful for a
1999-08-06 19:35:18 +02:00
fontserver.</para>
<para > For example, to convert the 30f9 Barcode font using the
default file names, use the following command:</para>
1999-10-10 20:35:50 +02:00
<screen > <prompt > %</prompt> <userinput > gs -dNODISPLAY -- ttf2pf.ps 3of9.ttf</userinput>
1999-08-06 19:35:18 +02:00
Aladdin Ghostscript 5.10 (1997-11-23)
Copyright (C) 1997 Aladdin Enterprises, Menlo Park, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Converting 3of9.ttf to 3of9.pfa and 3of9.afm.
</screen>
<para > If you want the converted fonts to be stored in
<filename > A.pfa</filename> and <filename > B.afm</filename> ,
then use this command:</para>
1999-10-10 20:35:50 +02:00
<screen > <prompt > %</prompt> <userinput > gs -dNODISPLAY -- ttf2pf.ps 3of9.ttf A B</userinput>
1999-08-06 19:35:18 +02:00
Aladdin Ghostscript 5.10 (1997-11-23)
Copyright (C) 1997 Aladdin Enterprises, Menlo Park, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Converting 3of9.ttf to A.pfa and B.afm.
</screen>
</listitem>
<listitem >
2005-04-23 00:46:19 +02:00
<para > Create the <application > groff</application> PostScript file:</para>
1999-08-06 19:35:18 +02:00
<para > Change directories to
<filename > /usr/share/groff_font/devps</filename> so as to
2001-10-16 13:53:01 +02:00
make the following command easier to execute. You will
probably need root privileges for this. (Or, if you are
1999-08-06 19:35:18 +02:00
paranoid about working there, make sure you reference the
files <filename > DESC</filename> ,
<filename > text.enc</filename> and
<filename > generate/textmap</filename> as being in this
directory.)</para>
1999-10-10 20:35:50 +02:00
<screen > <prompt > %</prompt> <userinput > afmtodit -d DESC -e text.enc file.afm \
2014-04-29 23:08:25 +02:00
generate/textmap <replaceable > PS_font_name</replaceable> </userinput>
1999-08-06 19:35:18 +02:00
</screen>
<para > Where, <filename > file.afm</filename> is the
<replaceable > AFM_name</replaceable> created by
<command > ttf2pf.ps</command> above, and
<replaceable > PS_font_name</replaceable> is the font name
used from that command, as well as the name that
1999-10-10 20:35:50 +02:00
&man.groff.1; will use for references to this font. For
example, assuming you used the first
<command > tiff2pf.ps</command> command above, then the 3of9
Barcode font can be created using the command:</para>
<screen > <prompt > %</prompt> <userinput > afmtodit -d DESC -e text.enc 3of9.afm \
1999-08-06 19:35:18 +02:00
generate/textmap 3of9</userinput>
</screen>
<para > Ensure that the resulting
<replaceable > PS_font_name</replaceable> file (e.g.,
<filename > 3of9</filename> in the example above) is located
in the directory
<filename > /usr/share/groff_font/devps</filename> by copying
or moving it there.</para>
<para > Note that if <filename > ttf2pf.ps</filename> assigns a
font name using the one it finds in the TrueType font file
and you want to use a different name, you must edit the
<filename > .afm</filename> file prior to running
<command > afmtodit</command> . This name must also match the
one used in the Fontmap file if you wish to pipe
1999-10-10 20:35:50 +02:00
&man.groff.1; into &man.gs.1; .</para>
1999-08-06 19:35:18 +02:00
</listitem>
</orderedlist>
1999-10-04 23:31:02 +02:00
</sect1>
1999-08-06 19:35:18 +02:00
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "truetype-for-other-programs" >
1999-10-10 20:35:50 +02:00
<title > Can TrueType fonts be used with other programs?</title>
<para > The TrueType font format is used by Windows, Windows 95, and
Mac's. It is quite popular and there are a great number of
fonts available in this format.</para>
<para > Unfortunately, there are few applications that I am aware of
2012-08-21 21:16:02 +02:00
that can use this format: <application > Ghostscript</application>
2005-04-23 00:46:19 +02:00
and <application > Povray</application> come to mind.
<application > Ghostscript's</application> support, according to the documentation, is
1999-10-10 20:35:50 +02:00
rudimentary and the results are likely to be inferior to type 1
2005-04-23 00:46:19 +02:00
fonts. <application > Povray</application> version 3 also has the ability to use TrueType
1999-10-10 20:35:50 +02:00
fonts, but I rather doubt many people will be creating documents
as a series of raytraced pages :-).</para>
2013-11-07 16:39:28 +01:00
<para > This rather dismal situation may soon change. The <link xlink:href= "http://www.freetype.org/" > FreeType Project</link> is
1999-10-10 20:35:50 +02:00
currently developing a useful set of FreeType tools:</para>
<itemizedlist >
2001-04-09 11:59:33 +02:00
1999-10-10 20:35:50 +02:00
<listitem >
2005-04-23 00:46:19 +02:00
<para > The <command > xfsft</command> font server for <application > X11</application> can
1999-10-10 20:35:50 +02:00
serve TrueType fonts in addition to regular fonts. Though
2001-07-10 16:00:17 +02:00
currently in beta, it is said to be quite usable. See
2013-11-07 16:39:28 +01:00
<link xlink:href= "http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/" > Juliusz
Chroboczek's page</link> for further information.
Porting instructions for FreeBSD can be found at <link xlink:href= "http://math.missouri.edu/~stephen/software/" > Stephen
Montgomery's software page</link> .</para>
1999-10-10 20:35:50 +02:00
</listitem>
<listitem >
2012-08-21 21:16:02 +02:00
<para > <application > xfstt</application> is another font server for
2005-04-23 00:46:19 +02:00
<application > X11</application> ,
2013-11-07 16:39:28 +01:00
available under <uri xlink:href= " ftp://sunsite.unc.edu/pub/Linux/X11/fonts/" > ftp://sunsite.unc.edu/pub/Linux/X11/fonts/</uri> .</para>
1999-10-10 20:35:50 +02:00
</listitem>
<listitem >
<para > A program called <command > ttf2bdf</command> can produce
BDF files suitable for use in an X environment from TrueType
2013-11-07 16:39:28 +01:00
files. Linux binaries are said to be available from <uri xlink:href= "ftp://crl.nmsu.edu/CLR/multiling/General/" > ftp://crl.nmsu.edu/CLR/multiling/General/</uri> .</para>
1999-10-10 20:35:50 +02:00
</listitem>
<listitem >
<para > and others … </para>
</listitem>
</itemizedlist>
</sect1>
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "obtaining-additional-fonts" >
1999-10-10 20:35:50 +02:00
<title > Where can additional fonts be obtained?</title>
<para > Many fonts are available on the Internet. They are either
entirely free, or are share-ware. In addition, there are many
inexpensive CDROMs available that contain many fonts. Some
Internet locations (as of August 1996) are:</para>
<itemizedlist >
<listitem >
2013-11-07 16:39:28 +01:00
<para > <uri xlink:href= "http://www.simtel.net/" > http://www.simtel.net/</uri> </para>
1999-10-10 20:35:50 +02:00
</listitem>
<listitem >
2013-11-07 16:39:28 +01:00
<para > <uri xlink:href= "http://www.freshmeat.net/" > http://www.freshmeat.net/</uri> </para>
1999-10-10 20:35:50 +02:00
</listitem>
<listitem >
2012-08-21 21:16:02 +02:00
<para > Checkout the fonts that come with the Ports Collection in
2005-04-26 00:13:49 +02:00
<filename > x11-fonts/</filename> </para>
1999-10-10 20:35:50 +02:00
</listitem>
</itemizedlist>
</sect1>
2013-11-07 16:39:28 +01:00
<sect1 xml:id= "additional-questions" >
1999-10-10 20:35:50 +02:00
<title > Additional questions</title>
<itemizedlist >
<listitem >
<para > What use are the <filename > .pfm</filename> files?</para>
</listitem>
<listitem >
<para > Can one generate the <filename > .afm</filename> file from
a <filename > .pfa</filename> or
<filename > .pfb</filename> ?</para>
</listitem>
<listitem >
2005-04-23 00:46:19 +02:00
<para > How to generate the <application > groff</application> character mapping files for
2003-08-14 21:54:05 +02:00
PostScript fonts with non-standard character names?</para>
1999-10-10 20:35:50 +02:00
</listitem>
<listitem >
2003-11-05 11:59:35 +01:00
<para > Can xditview and devX?? devices be set up to access all
1999-10-10 20:35:50 +02:00
the new fonts?</para>
</listitem>
<listitem >
<para > It would be good to have examples of using TrueType
2005-04-23 00:46:19 +02:00
fonts with <application > Povray</application> and <application > Ghostscript</application> .</para>
1999-10-10 20:35:50 +02:00
</listitem>
</itemizedlist>
</sect1>
1999-10-04 23:31:02 +02:00
</article>