\HeaderA{embedFonts}{Embed Fonts in PostScript and PDF}{embedFonts}
\keyword{device}{embedFonts}
\begin{Description}\relax
Runs Ghostscript to process a PDF or PostScript file and
embed all fonts in the file.
\end{Description}
\begin{Usage}
\begin{verbatim}
embedFonts(file, format, outfile = file, fontpaths = "",
           options = "")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{file}] a character string giving the name of the original file.
\item[\code{format}] either \code{"pswrite"} or \code{"pdfwrite"}.
If not specified, it is guessed from the suffix of \code{file}.
\item[\code{outfile}] the name of the new file (with fonts embedded).
\item[\code{fontpaths}] a character vector giving directories that
Ghostscript will search for fonts.
\item[\code{options}] a character string containing further options to
Ghostscript.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This function is not necessary if you just use the standard
default fonts for PostScript and PDF output.

If you use a special font, this function is useful for
embedding that font in your PostScript or PDF document
so that it can be shared with others without them having
to install your special font (provided the font licence allows this).

If the special font is not installed for Ghostscript,
you will need to tell Ghostscript where the font is, using
something like \code{options="-sFONTPATH=path/to/font"}.

This function relies on a suitable Ghostscript executable being in
your path, or the environment variable \env{R\_GSCMD} (the same as
\code{\LinkA{bitmap}{bitmap}}) being set as the full path to the Ghostscript
executable.
This defaults to \code{"gs"}.

Note that Ghostscript may do font substitution, so the font embedded
may differ from that specified in the original file.
\end{Details}
\begin{Value}
The shell command used to invoke Ghostscript is returned
invisibly. This may be useful for debugging purposes as
you can run the command by hand in a shell to look for problems.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{postscriptFonts}{postscriptFonts}},
\code{\LinkA{Devices}{Devices}}.

Paul Murrell and Brian Ripley (2006) Non-standard fonts in PostScript
and PDF graphics. \emph{R News}, 6(2):41--47.
\url{http://cran.r-project.org/doc/Rnews/Rnews_2006-2.pdf}.
\end{SeeAlso}

