next up previous contents index
Next: Postscript prologue Up: Postscript Previous: Editing postscript   Contents   Index


Postscript fontfile

The fontfile or fontfile add option takes one file name as argument and encapsulates this file into the postscript output in order to make this font available for text elements (labels, tic marks, titles, etc.). The fontfile delete option also takes one file name as argument. It deletes this file name from the list of encapsulated files.

The postscript terminal understands some font file formats: Type 1 fonts in ASCII file format (extension ".pfa"), Type 1 fonts in binary file format (extension ".pfb"), and TrueType fonts (extension ".ttf"). Pfa files are understood directly, pfb and ttf files are converted on the fly if appropriate conversion tools are installed (see below). You have to specify the full filename including the extension. Each fontfile option takes exact one font file name. This option can be used multiple times in order to include more than one font file.

The font file is searched in the working directory and in all directories listed in the fontpath which is determined by set fontpath. In addition, the fontpath can be set using the environment variable GNUPLOT_FONTPATH. If this is not set a system dependent default search list is used. See set fontpath (p. [*]) for more details.

For using the encapsulated font file you have to specify the font name (which normally is not the same as the file name). When embedding a font file by using the fontfile option in interactive mode, the font name is printed on the screen. E.g.

  Font file 'p052004l.pfb' contains the font 'URWPalladioL-Bold'. Location:
  /usr/lib/X11/fonts/URW/p052004l.pfb

When using pfa or pfb fonts, you can also find it out by looking into the font file. There is a line similar to "/FontName /URWPalladioL-Bold def". The middle string without the slash is the fontname, here "URWPalladioL-Bold". For TrueType fonts, this is not so easy since the font name is stored in a binary format. In addition, they often have spaces in the font names which is not supported by Type 1 fonts (in which a TrueType is converted on the fly). The font names are changed in order to eliminate the spaces in the fontnames. The easiest way to find out which font name is generated for use with gnuplot, start gnuplot in interactive mode and type in "set terminal postscript fontfile '5#5filename.ttf6#6'".

For converting font files (either ttf or pfb) to pfa format, the conversion tool has to read the font from a file and write it to standard output. If the output cannot be written to standard output, on-the-fly conversion is not possible.

For pfb files "pfbtops" is a tool which can do this. If this program is installed on your system the on the fly conversion should work. Just try to encapsulate a pfb file. If the compiled in program call does not work correctly you can specify how this program is called by defining the environment variable GNUPLOT_PFBTOPFA e.g. to "pfbtops %s". The %s will be replaced by the font file name and thus has to exist in the string.

If you don't want to do the conversion on the fly but get a pfa file of the font you can use the tool "pfb2pfa" which is written in simple c and should compile with any c compiler. It is available from many ftp servers, e.g.

ftp://ftp.dante.de/tex-archive/fonts/utilities/ps2mf/ftp://ftp.dante.de/tex-archive/fonts/utilities/ps2mf/

In fact, "pfbtopfa" and "pfb2ps" do the same job. "pfbtopfa" puts the resulting pfa code into a file, whereas "pfbtops" writes it to standard output.

TrueType fonts are converted into Type 1 pfa format, e.g. by using the tool "ttf2pt1" which is available from

http://ttf2pt1.sourceforge.net/http://ttf2pt1.sourceforge.net/

If the builtin conversion does not work, the conversion command can be changed by the environment variable GNUPLOT_TTFTOPFA. For usage with ttf2pt1 it may be set to "ttf2pt1 -a -e -W 0 %s - ". Here again, %s stands for the file name.

For special purposes you also can use a pipe (if available for your operating system). Therefore you start the file name definition with the character "5#5" and append a program call. This program has to write pfa data to standard output. Thus, a pfa file may be accessed by set fontfile "5#5 cat garamond.pfa".

For example, including Type 1 font files can be used for including the postscript output in LaTeX documents. The "european computer modern" font (which is a variant of the "computer modern" font) is available in pfb format from any CTAN server, e.g.

ftp://ftp.dante.de/tex-archive/fonts/ps-type1/cm-super/ftp://ftp.dante.de/tex-archive/fonts/ps-type1/cm-super/

For example, the file "sfrm1000.pfb" contains the normal upright fonts with serifs in the design size 10pt (font name "SFRM1000"). The computer modern fonts, which are still necessary for mathematics, are available from

ftp://ftp.dante.de/tex-archive/fonts/cm/ps-type1/blueskyftp://ftp.dante.de/tex-archive/fonts/cm/ps-type1/bluesky

With these you can use any character available in TeX. However, the computer modern fonts have a strange encoding. (This is why you should not use cmr10.pfb for text, but sfrm1000.pfb instead.) The usage of TeX fonts is shown in one of the demos. The file "ps_fontfile_doc.tex" in the /docs/psdoc subdirectory of the gnuplot source distribution contains a table with glyphs of the TeX mathfonts.

If the font "CMEX10" is embedded (file "cmex10.pfb") gnuplot defines the additional font "CMEX10-Baseline". It is shifted vertically in order to fit better to the other glyphs (CMEX10 has its baseline at the top of the symbols).


next up previous contents index
Next: Postscript prologue Up: Postscript Previous: Editing postscript   Contents   Index
Ethan Merritt 2007-03-03