\HeaderA{postscriptFonts}{PostScript and PDF Font Families}{postscriptFonts}
\aliasA{pdfFonts}{postscriptFonts}{pdfFonts}
\keyword{device}{postscriptFonts}
\begin{Description}\relax
These functions handle the translation of a \R{} graphics
font family name to a PostScript or PDF font description, used by the
\code{\LinkA{postscript}{postscript}} or \code{\LinkA{pdf}{pdf}} graphics devices.
\end{Description}
\begin{Usage}
\begin{verbatim}
postscriptFonts(...)
pdfFonts(...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{...}] either character strings naming mappings to display,
or named arguments specifying mappings to add or change.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If these functions are called with no argument they list all the
existing mappings, whereas if they are called with named arguments
they add (or change) mappings.

A PostScript or PDF device is created with a default font family (see the
documentation for \code{\LinkA{postscript}{postscript}}), but it is also possible
to specify a font family when drawing to the device (for example, see
the documentation for \code{"family"} in \code{\LinkA{par}{par}} and for
\code{"fontfamily"} in \code{\LinkA{gpar}{gpar}} in the \pkg{grid} package).

The font family sent to the device is a simple string name, which must be
mapped to a set of PostScript fonts.  Separate lists of mappings for
\code{postscript} and \code{pdf} devices are  maintained for the
current \R{} session and can be added to by the user.

The \code{postscriptFonts} and \code{pdfFonts} functions can be used
to list existing mappings and to define new mappings.  The
\code{\LinkA{Type1Font}{Type1Font}} and \code{\LinkA{CIDFont}{CIDFont}} functions can be
used to create new mappings, when the \code{xxxFonts} function is used
to add them to the database.  See the examples.

Default mappings are provided for three device-independent family
names: \code{"sans"} for a sans-serif font (to \code{"Helvetica"}),
\code{"serif"} for a serif font (to \code{"Times"}) and \code{"mono"}
for a monospaced font (to \code{"Courier"}).

Mappings for a number of standard Adobe fonts (and URW equivalents)
are also provided: \code{"AvantGarde"},
\code{"Bookman"}, \code{"Courier"}, \code{"Helvetica"},
\code{"Helvetica-Narrow"}, \code{"NewCenturySchoolbook"},
\code{"Palatino"} and \code{"Times"};
\code{"URWGothic"}, \code{"URWBookman"}, \code{"NimbusMon"},
\code{"NimbusSan"} (synonym \code{"URWHelvetica"}),
\code{"NimbusSanCond"}, \code{"CenturySch"}, \code{"URWPalladio"} and
\code{"NimbusRom"} (synonym \code{"URWTimes"}).

There are also mappings for \code{"ComputerModern"} and
\code{"ComputerModernItalic"}.

Finally, there are some default mappings for East Asian locales
described in a separate section.

The specification of font metrics and encodings is described in the help
for the \code{\LinkA{postscript}{postscript}} function.

The fonts are not embedded in the resulting PostScript or PDF file, so
software including the PostScript or PDF plot file should either embed
the font outlines (usually from \file{.pfb} or \file{.pfa} files) or
use DSC comments to instruct the print spooler or including
application to do so (see also \code{\LinkA{embedFonts}{embedFonts}}).

A font family has both an \R-level name, the argument name used when
\code{postscriptFonts} was called, and an internal name, the
\code{family} component.  These two names are the same for all the
pre-defined font families.

Once a font family is in use it cannot be changed.  \sQuote{In use}
means that it has been specified \emph{via} a \code{family} or
\code{fonts} argument to an invocation of the same graphics device
already in the \R{} session.  (For these purposes \code{xfig} counts the
same as \code{postscript} but only uses some of the predefined mappings.)
\end{Details}
\begin{Value}
A list of one or more font mappings.
\end{Value}
\begin{Section}{East Asian fonts}
There are some default mappings for East Asian locales:\\
\code{"Japan1"}, \code{"Japan1HeiMin"}, \code{"Japan1GothicBBB"},
and \code{"Japan1Ryumin"} for Japanese;
\code{"Korea1"} and \code{"Korea1deb"} for Korean;
\code{"GB1"} (Simplified Chinese) for mainland China and Singapore;
\code{"CNS1"} (Traditional Chinese) for Hong Kong and Taiwan.

These refer to the following fonts
\Tabular{ll}{
Japan1 (PS) & \code{HeiseiKakuGo-W5}\\ & Linotype Japanese printer font\\
Japan1 (PDF) & \code{KozMinPro-Regular-Acro}\\ & from Adobe Reader 7.0 Japanese Font Pack\\
Japan1HeiMin (PS) & \code{HeiseiMin-W3}\\ & Linotype Japanese printer font\\
Japan1HeiMin (PDF) & \code{HeiseiMin-W3-Acro}\\ & from Adobe Reader 7.0 Japanese Font Pack\\
Japan1GothicBBB & \code{GothicBBB-Medium}\\ & Japanese-market PostScript printer font\\
Japan1Ryumin & \code{Ryumin-Light}\\ & Japanese-market PostScript printer font\\
Korea1 (PS) & \code{Baekmuk-Batang}\\  & TrueType font found on some Linux systems\\
Korea1 (PDF) & \code{HYSMyeongJoStd-Medium-Acro}\\  & from Adobe Reader 7.0 Korean Font Pack\\
Korea1deb (PS) & \code{Batang-Regular}\\  & another name for Baekmuk-Batang\\
Korea1deb (PDF) & \code{HYGothic-Medium-Acro}\\  & from Adobe Reader 4.0 Korean Font Pack\\
GB1 (PS) & \code{BousungEG-Light-GB}\\  & TrueType font found on some Linux systems\\
GB1 (PDF) & \code{STSong-Light-Acro}\\  & from Adobe Reader 7.0 Simplified Chinese Font Pack\\
CNS1 (PS) & \code{MOESung-Regular}\\ & Ken Lunde's CJKV resources\\
CNS1 (PDF) & \code{MSungStd-Light-Acro}\\  & from Adobe Reader 7.0 Traditional Chinese Font Pack\\
}
\code{Baekmuk-Batang} can be found at \url{ftp://ftp.mizi.com/pub/baekmuk/}.
\code{BousungEG-Light-GB} can be found at
\url{ftp://ftp.gnu.org/pub/non-gnu/chinese-fonts-truetype/}.
Ken Lunde's CJKV resources are at
\url{ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/samples/}.
These will need to be installed or otherwise made available to the
postscript/PDF interpreter such as ghostscript (and not all
interpreters can handle TrueType fonts).

You may well find that your postscript/PDF interpreters has been set
up to provide aliases for many of these fonts.  For example,
ghostscript on Windows can optionally be installed to map common CJK
fonts names to Windows TrueType fonts.  (You may want to add the
\code{-Acro} versions as well.)

Adding a mapping for a CID-keyed font is for gurus only.
\end{Section}
\begin{Author}\relax
Support for Computer Modern fonts is based on a contribution by
Brian D'Urso \email{durso@hussle.harvard.edu}.
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{postscript}{postscript}} and \code{\LinkA{pdf}{pdf}};  \code{\LinkA{Type1Font}{Type1Font}}
and \code{\LinkA{CIDFont}{CIDFont}} for specifying new font mappings.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
postscriptFonts()
## This duplicates "ComputerModernItalic".
CMitalic <- Type1Font("ComputerModern2",
                      c("CM_regular_10.afm", "CM_boldx_10.afm",
                        "cmti10.afm", "cmbxti10.afm",
                         "CM_symbol_10.afm"),
                      encoding = "TeXtext.enc")
postscriptFonts(CMitalic = CMitalic)

## A CID font for Japanese using a different CMap and
## corresponding cmapEncoding.
`Jp_UCS-2` <- CIDFont("TestUCS2",
                  c("Adobe-Japan1-UniJIS-UCS2-H.afm",
                    "Adobe-Japan1-UniJIS-UCS2-H.afm",
                    "Adobe-Japan1-UniJIS-UCS2-H.afm",
                    "Adobe-Japan1-UniJIS-UCS2-H.afm"),
                  "UniJIS-UCS2-H", "UCS-2")
pdfFonts(`Jp_UCS-2` = `Jp_UCS-2`)
names(pdfFonts())
\end{ExampleCode}
\end{Examples}

