TCM
UoC crest

Arbitrary Fonts in Gnuplot and XMGrace

Sometimes it is useful to be able to use a non-standard font in a graph. This page describes how to do so for gnuplot and xmgr.

Gnuplot

First find your font in Type1 .pfa form. It is likely to be in .pfb form, so you may need to use pfb2pfa.

Specify the font file when setting the terminal type:

set term post eps enh fontfile "cmsy10.pfa"

Use the font in any label as one would any standard font.

set xlabel "{/CMSY10 A} (Arbitrary Units}"
(Note that the name used at this point is the PostScript font name as specified in the font file, not necessarily the filename.)

A guide to using the features of the enhanced PostScript terminal type should be in Gnuplot's install tree as docs/psdoc/ps_guide.ps.

XMGrace

First create your own .grace/fonts/type1 directory, and populate with the contents of the system Grace fonts/type1 directory (preferably using symlinks, and the .afm files are not required). Copy also the file fonts/FontDataBase from the system directory to your own .grace/fonts directory.

Add any additional .pfa or .pfb fonts to your .grace/fonts/type1 directory. Edit your fonts/FontDataBase to reflect this. The first line is the total number of fonts, subsequent lines are name (PostScript), name (again), filename. Note that the exact, full PostScript name of the font must be used, e.g. ZapfChancery-MediumItalic.

Alternatively, do not create a type1 directory, and ensure that the full pathname appears in the FontDataBase file for any font not in the system type1 directory. In other words, if you have a type1 directory, the system one will be ignored completely.

Start xmgrace. The additional fonts should appear in all font selection lists. One can also select different fonts within a string by following the control codes described in the XMGrace User Guide, which may be found locally here

Print by selecting `EPS' and `Use Device Fonts'. This causes no fonts to be embedded. (Unchecking `Use Device Fonts' causes all fonts to be converted to bitmaps.)

Convert the fonts needed to .pfa and insert them directly into the EPS after the %%EndComments line. Remove the corresponding lines from %%DocumentNeededResources: lines at the end of the EPS file. (If the font is one of the standard `PostScript 35', this paragraph should be unnecessary.)

Useful Fonts

The LaTeX fonts tend to be useful and freely distributable. They are probably found somewhere like
.../texmf/fonts/type1/bluesky/cm/
for the Computer Modern ones. Therein cmmi12.pfb is Computer Modern Maths Italic, and cmsy10.pfb contains the Maths Calligraphic font (uppercase only). One can also try finding these fonts by using kpsewhich.

pc0~:$ kpsewhich cmmi12.pfb
/usr/share/texmf/fonts/type1/public/amsfonts/cm/cmmi12.pfb

Similarly ghostscripts fonts. They have bizarre filenames, but are probably indexed by a fonts.dir file. They will be found under
.../share/fonts/
and include the full `PostScript 35'. For further hints on where ghostscript might be finding its fonts, try gs -h.