The libplot
vector graphics library and applications built on
it, such as graph
and plot
, can draw text strings in a
wide variety of fonts. Text strings may include characters from more
than one font in a typeface, and may include superscripts, subscripts,
and square roots. A wide variety of plotting symbols can also be
drawn. The following sections explain how to use these features.
The libplot
library and applications built on it, such as
graph
, plot
, tek2plot
, and pic2plot
, can use
many fonts. These include 22 Hershey vector fonts, 35 Postscript fonts,
45 PCL 5 fonts, and 18 Hewlett--Packard vector fonts. We call
these 120 supported fonts the `built-in' fonts. The Hershey fonts are
constructed from stroked characters digitized c. 1967 by Dr.
Allen V. Hershey at the U.S. Naval Surface Weapons Center in
Dahlgren, VA. The 35 Postscript fonts are the outline fonts
resident in all modern Postscript printers, and the 45 PCL 5 fonts
are the outline fonts resident in modern Hewlett--Packard LaserJet
printers and plotters. (The old LaserJet III, which was
Hewlett--Packard's first PCL 5 printer, supported only 8 of the
45.) The 18 Hewlett--Packard vector fonts are fonts that are resident
in Hewlett--Packard printers and plotters (mostly the latter).
The Hershey fonts can be used by all types of Plotter supported by
libplot
, and the Postscript fonts can be used by X, Illustrator,
Postscript, and Fig Plotters. So, for example, all variants of
graph
can use the Hershey fonts, and graph -T X
,
graph -T ai
, graph -T ps
and graph -T fig
can use
the Postscript fonts. The PCL 5 fonts can be used by by
Illustrator, PCL, and HP-GL Plotters, and by graph -T ai
,
graph -T pcl
, and graph -T hpgl
. The Hewlett--Packard
vector fonts can be used by by PCL and HP-GL Plotters, and by
graph -T pcl
and graph -T hpgl
. X Plotters and
graph -T X
are not restricted to the built-in Hershey and
Postscript fonts. They can use any X Window System font.
The plotfont
utility, which accepts the `-T' option, will
print a character map of any font that is available in the specified
output format. See section The plotfont
Utility.
For the purpose of plotting text strings (see section Text string format and escape sequences), the 120 built-in fonts are divided into typefaces. As you can see from the following tables, our convention is that in any typeface with more than a single font, font #1 is the normal font, font #2 is italic or oblique, font #3 is bold, and font #4 is bold italic or bold oblique. Additional variants (if any) are numbered #5 and higher.
The 22 Hershey fonts are divided into typefaces as follows.
Nearly all Hershey fonts except the Symbol fonts use the ISO-Latin-1 encoding, which is a superset of ASCII. The Symbol fonts consist of Greek characters and mathematical symbols, and use the symbol font encoding documented in the Postscript Language Reference Manual. By convention, each Hershey typeface contains a symbol font (HersheySerifSymbol or HersheySansSymbol, as appropriate) as font #0.
HersheyCyrillic, HersheyCyrillic-Oblique, and HersheyEUC (which is a Japanese font) are the only non-Symbol Hershey fonts that do not use the ISO-Latin-1 encoding. For their encodings, see section Cyrillic and Japanese fonts.
The 35 Postscript fonts are divided into typefaces as follows.
All Postscript fonts except the ZapfDingbats and Symbol fonts use the ISO-Latin-1 encoding. The encodings used by the ZapfDingbats and Symbol fonts are documented in the Postscript Language Reference Manual. By convention, each Postscript typeface contains the Symbol font as font #0.
The 45 PCL 5 fonts are divided into typefaces as follows.
All PCL 5 fonts except the Wingdings and Symbol fonts use the ISO-Latin-1 encoding. The encoding used by the Symbol font is the symbol font encoding documented in the Postscript Language Reference Manual. By convention, each PCL typeface contains the Symbol font as font #0.
The 18 Hewlett--Packard vector fonts are divided into typefaces as follows.
The Hewlett--Packard vector fonts with an asterisk (the ANK and Symbol
fonts) are only available when producing HP-GL output for the HP7550A
graphics plotter and the HP758x, HP7595A and HP7596A drafting plotters.
The ANK fonts are Japanese fonts (see section Cyrillic and Japanese fonts), and
the Symbol fonts contain a few miscellaneous mathematical symbols.
To ensure that these fonts are available, you must set the
environment variable or driver parameter HPGL_VERSION
to "1.5".
All Hewlett--Packard vector fonts except the ANK and Symbol fonts use
the ISO-Latin-1 encoding. The Arc fonts are proportional
(variable-width) fonts, and the Stick fonts are fixed-width fonts. If
HPGL_VERSION
is "1.5" then the Arc fonts will be kerned. But if
HPGL_VERSION
is "2" (the default), there will be no kerning.
Apparently Hewlett--Packard dropped support for device-resident kerning
tables when moving from HP-GL to modern HP-GL/2 and PCL 5. For
information about Hewlett--Packard vector fonts and the way in which
they are kerned (in pen plotters, at least), see the article by
L. W. Hennessee et al. in the Nov. 1981 issue of the
Hewlett--Packard Journal.
To what extent do the fonts supported by libplot
contain
ligatures? The Postscript fonts, the PCL 5 fonts, and the
Hewlett--Packard vector fonts, at least as implemented in
libplot
, do not contain ligatures. However, six of the 22
Hershey fonts contain ligatures. The character combinations "fi", "ff",
"fl", "ffi", and "ffl" are automatically drawn as ligatures in
HersheySerif and HersheySerif-Italic. (Also in the two HersheyCyrillic
fonts and HersheyEUC, since insofar as printable ASCII characters are
concerned, they are identical [or almost identical] to HersheySerif.)
In addition, "tz" and "ch" are ligatures in HersheyGothicGerman.
The German double-s character `@ss{'}, which is called an `eszet',
is not treated as a ligature in any font. To obtain an eszet, you
must either request one with the escape sequence "\ss" (see section Text string format and escape sequences), or, if you have an 8-bit keyboard, type an eszet
explicitly.
The built-in fonts discussed in the previous section include Cyrillic
and Japanese vector fonts. This section explains how these fonts are
encoded, i.e., how their character maps are laid out. You may use
the plotfont
utility to display the character map for any font,
including the Cyrillic and Japanese vector fonts. See section The plotfont
Utility.
The HersheyCyrillic and HersheyCyrillic-Oblique fonts use an encoding called KOI8-R, a superset of ASCII that has become the de facto standard for Unix and networking applications in the former Soviet Union. Insofar as printable ASCII characters go, they resemble the HersheySerif vector font. But their upper halves are different. The byte range 0xc0...0xdf contains lower-case Cyrillic characters and the byte range 0xe0...0xff contains upper case Cyrillic characters. Additional Cyrillic characters are located at 0xa3 and 0xb3. For more on the encoding scheme, see the official KOI8-R Web page and Internet RFC 1489, which is available from the Information Sciences Institute.
The HersheyEUC font is a vector font that is is used for displaying Japanese text. It uses the 8-bit EUC-JP encoding. EUC stands for `extended Unix code', which is a scheme for encoding Japanese, and also other character sets (e.g., Greek and Cyrillic) as multibyte character strings. The format of EUC strings is explained in Ken Lunde's Understanding Japanese Information Processing (O'Reilly, 1993), which contains much additional information on Japanese text processing. See also his on-line supplement.
In the HersheyEUC font, characters in the printable ASCII range,
0x20...0x7e, are similar to HersheySerif (their encoding is
`JIS Roman', an ASCII variant standardized by the Japanese Industrial
Standards Committee). Also, each successive pair of bytes in the
0xa1
...0xfe
range defines a single character in the
JIS X0208 standard. The characters in the JIS X0208 standard include
Japanese syllabic characters (Hiragana and Katakana), ideographic
characters (Kanji), Roman, Greek, and Cyrillic alphabets, punctuation
marks, and miscellaneous symbols. For example, the JIS X0208 standard
indexes the 83 Hiragana as 0x2421
...0x2473
. To
obtain the EUC code for any JIS X0208 character, you would add
0x80
to each byte (i.e., `set the high bit' on each byte). So
the first of the 83 Hiragana (0x2421
) would be encoded as the
successive pair of bytes 0xa4
and 0xa1
.
The implementation of the JIS X0208 standard in the HersheyEUC font is based on Dr. Hershey's digitizations, and is complete enough to be useful. All 83 Hiragana and 86 Katakana are available, though the little-used `half-width Katakana' are not supported. Also, 603 Kanji are available, including 596 of the 2965 JIS Level 1 (i.e., frequently used) Kanji. The Hiragana, the Katakana, and the available Kanji all have the same width. The file `kanji.doc', which on most systems is installed in `/usr/share/libplot' or `/usr/local/share/libplot', lists the 603 available Kanji. Each JIS X0208 character that is unavailable will be drawn as an `undefined character' glyph (a bundle of horizontal lines).
The eight Hewlett--Packard vector fonts in the ArcANK and StickANK
typefaces are also used for displaying Japanese text. They are
available when producing HP-GL output for the HP7550A graphics plotter
and the HP758x, HP7595A and HP7596A drafting plotters. To ensure
that they are available, you must set the environment variable or driver
parameter HPGL_VERSION
to "1.5".
ANK stands for Alphabet, Numerals, and Katakana. The ANK fonts use the `Kana-8' encoding. The lower half of each font uses the JIS Roman encoding, and the upper half contains half-width Katakana. Half-width Katakana are simplified Katakana that may need to be equipped with diacritical marks. The diacritical marks are included in the encoding, as separate characters.
The plotting utilities graph -T X
, plot -T X
,
tek2plot -T X
, pic2plot -T X
, and plotfont
-T X
, and the libplot
library that they are built on,
can draw text on an X Window System display in a wide variety of
fonts. This includes the 22 built-in Hershey vector fonts. They can
use the 35 built-in Postscript fonts too, if those fonts are available
on the X display. Most releases of the plotting utilities include
freely distributable versions of the 35 Postscript fonts, in Type 1
format, that are easily installed on any X display.
In fact, the plotting utilities can use most fonts that are available on the current X display. This includes all scalable fonts that have a so-called XLFD (X Logical Font Description) name. For example, the "CharterBT-Roman" font is available on many X displays. It has a formal XLFD name, namely "-bitstream-charter-medium-r-normal--0-0-0-0-p-0-iso8859-1". The plotting utilities would refer to it as "charter-medium-r-normal". The command
echo 0 0 1 1 2 0 | graph -T X -F charter-medium-r-normal
would draw a plot in a popped-up X window, in which all axis ticks are labeled in this font.
You may determine which fonts are available on an X display by using
the xlsfonts
command. Fonts whose names end in
"-0-0-0-0-p-0-iso8859-1" or "-0-0-0-0-m-0-iso8859-1" are scalable
ISO-Latin-1 fonts that can be used by libplot
's X Plotters
and by the plotting utilities that are built on libplot
. The two
sorts of font are variable-width and fixed-width fonts, respectively.
Fonts whose names end in "iso8859-2", etc., and "adobe-fontspecific",
may also be used, even though they do not employ the standard
ISO-Latin-1 encoding.
The escape sequences that provide access to the non-ASCII `8-bit' characters in the built-in ISO-Latin-1 fonts may be employed when using any ISO-Latin-1 X Window System font. For more on escape sequences, see section Text string format and escape sequences. As an example, "\Po" will yield the British pounds sterling symbol `@pounds{'}. The command
echo 0 0 1 1 | graph -T X -F charter-medium-r-normal -L "A \Po1 Plot"
shows how this symbol could be used in a graph label. In the same way, the escape sequences that provide access to mathematical symbols and Greek characters may be employed when using any X Window System font, whether or not it is an ISO-Latin-1 font.
The plotting utilities, including graph
, support a
--bitmap-size
option. It is meaningful only if the
`-T X' option is used, since it sets the size of the popped-up
X Window. You may use it to obtain some interesting visual effects.
Each of the plotting utilities assumes that it is drawing in a square
region, so if you use the `--bitmap-size 800x400' option, your plot
will be scaled anisotropically, by a larger factor in the horizontal
direction than in the vertical direction. The fonts in the plot will be
scaled in the same way. Actually, this requires a modern (X11R6)
display. If your X display cannot scale a font, a default
scalable font (such as "HersheySerif") will be substituted.
Text strings that are drawn by libplot
, and by such applications
as graph
, plot
, tek2plot
, pic2plot
, and
plotfont
, which are built on libplot
, must consist of
printable characters. No embedded control characters, such as newlines
or carriage returns, are allowed. Technically, a character is
`printable' if it comes from either of the two byte ranges
0x20...0x7e and 0xa0...0xff. The former is the
printable ASCII range and the latter is the printable `8-bit' range.
Text strings may, however, include embedded `escape sequences' that
shift the font, append subscripts or superscripts, or include non-ASCII
characters and mathematical symbols. As a consequence, the axis labels
on a plot prepared with graph
may include such features. So may
the text strings that pic2plot
uses to label objects.
The format of the escape sequences should look familiar to anyone who is
familiar with the TeX or groff
document formatters. Each
escape sequence consists of three characters: a backslash and two
additional characters. The most frequently used escape sequences are as
follows.
For example, the string "x\sp2\ep" would be interpreted as `x squared'. Subscripts on subscripts, etc., are allowed. Subscripts and superscripts may be vertically aligned by judicious use of the "\mk" and "\rt" escape sequences. For example, "a\mk\sbi\eb\rt\sp2\ep" produces "a sub i squared", with the exponent `2' placed immediately above the subscript.
There are also escape sequences that switch from font to font within a
typeface. For an enumeration of the fonts within each typeface, see
section Available text fonts. Suppose for example that the current font is
Times-Roman, which is font #1 in the `Times' typeface. The string
"A \f2very\f1 well labeled axis" would be a string in which the word `very'
appears in Times-Italic rather than Times-Roman. That is because
Times-Italic is the #2 font in the typeface. Font-switching escape
sequences are of the form "\fn", where n is the number of
the font to be switched to. For compatibility with groff
,
"\fR", "\fI", "\fB" are equivalent to "\f1", "\f2", "\f3", respectively.
"\fP" will switch the font to the previously used font (only one font is
remembered). There is currently no support for switching between fonts
in different typefaces.
There are also a few escape sequences for horizontal shifts, which are useful for improving horizontal alignment, such as when shifting between italic and non-italic fonts. "\r1", "\r2", "\r4", "\r6", "\r8", and "\r^" are escape sequences that shift right by 1 em, 1/2 em, 1/4 em, 1/6 em, 1/8 em, and 1/12 em, respectively. "\l1", "\l2", "\l4", "\l6", "\l8", and "\l^" are similar, but shift left instead of right. "A \fIvery\r^\fP well labeled axis" would look slightly better than "A \fIvery\fP well labeled axis".
Square roots are handled with the aid of a special pair of escape sequences, together with the "\mk" and "\rt" sequences discussed above. A square root symbol is begun with "\sr", and continued arbitrarily far to the right with the overbar (`run') escape sequence, "\rn". For example, the string "\sr\mk\rn\rn\rtab" would be plotted as `the square root of ab'. To adjust the length of the overbar, you may need to experiment with the number of times "\rn" appears.
To underline a string, you would use "\ul", the underline escape sequence, one or more times. The "\mk"..."\rt" trick would be employed in the same way. So, for example, "\mk\ul\ul\ul\rtabc" would yield an underlined "abc". To adjust the length of the underline, you may need to experiment with the number of times "\ul" appears. You may also need to use one or more of the abovementioned horizontal shifts. For example, if the "HersheySerif" font were used, "\mk\ul\ul\l8\ul\rtabc" would yield a better underline than "\mk\ul\ul\ul\rtabc".
Besides the preceding escape sequences, there are also escape sequences for the printable non-ASCII characters in each of the built-in ISO-Latin-1 fonts (which means in every built-in font, except for the symbol fonts, the HersheyCyrillic fonts, HersheyEUC, and ZapfDingbats). The useful non-ASCII characters include accented characters among others. Such `8-bit' characters, in the 0xa0...0xff byte range, may be included directly in a text string. But if your terminal does not permit this, you may use the escape sequences for them instead.
There are escape sequences for the mathematical symbols and Greek characters in the symbol fonts, as well. This is how the symbol fonts are usually accessed. Which symbol font the mathematical symbols and Greek characters are taken from depends on whether your current font is a Hershey font or a non-Hershey font. They are taken from the HersheySerifSymbol font or the HersheySansSymbol font in the former case, and from the Symbol font in the latter.
The following are the escape sequences that provide access to the non-ASCII characters of the current font, provided that it is an ISO-Latin-1 font. Each escape sequence is followed by the position of the corresponding character in the ISO-Latin-1 encoding (in decimal), and the official Postscript name of the character. Most names should be self-explanatory. For example, `eacute' is a lower-case `e', equipped with an acute accent.
The following are the escape sequences that provide access to mathematical symbols and Greek characters in the current symbol font, whether HersheySerifSymbol or HersheySansSymbol (for Hershey fonts) or Symbol (for Postscript fonts). Each escape sequence is followed by the position (in octal) of the corresponding character in the symbol encoding, and the official Postscript name of the character. Many escape sequences and names should be self-explanatory. "\*a" represents a lower-case Greek alpha, for example. For a table displaying each of the characters below, see the Postscript Language Reference Manual.
Finally, there are escape sequences that apply only if the current font is a Hershey font. Most of these escape sequences provide access to special symbols that belong to no font, and are accessible by no other means. These symbols are of two sorts: miscellaneous, and astronomical or zodiacal. The escape sequences for the miscellaneous symbols are as follows.
The final escape sequence in the table above, "\s-", yields a letter rather than a symbol. It is provided because in some Hershey fonts, the shape of the lower-case letter `s' differs if it is the last letter in a word. This is the case for HersheyGothicGerman. The German word "besonders", for example, should be written as "besonder\s-" if it is to be rendered correctly in this font. The same is true for the two Hershey symbol fonts, with their Greek alphabets (in Greek text, lower-case final `s' is different from lower-case non-final `s'). In Hershey fonts where there is no distinction between final and non-final `s', "s" and "\s-" are equivalent.
The escape sequences for the astronomical symbols, including the signs for the twelve constellations of the zodiac, are listed in the following table. We stress that that like the preceding miscellaneous escape sequences, they apply only if the current font is a Hershey font.
The preceding miscellaneous and astronomical symbols are not the only
special non-font symbols that can be used if the current font is a
Hershey font. The entire library of glyphs digitized by Allen Hershey
is built into GNU libplot
. So text strings may include any
Hershey glyph. Each of the available Hershey glyphs is identified by a
four-digit number. Standard Hershey glyph #1 would be specified as
"\#H0001". The standard Hershey glyphs range from "\#H0001" to
"\#H3999", with a number of gaps. Some additional glyphs designed by
others appear in the "\#H4000"..."\#H4194" range. Syllabic Japanese
characters (Kana) are located in the "\#H4195"..."\#H4399" range.
You may order a table of nearly all the Hershey glyphs in the "\#H0001"..."\#H3999" range from the U.S. National Technical Information Service, at +1 703 487 4650. Ask for item number PB251845; the current price is about US$40. By way of example, the string
"\#H0744\#H0745\#H0001\#H0002\#H0003\#H0869\#H0907\#H2330\#H2331"
when drawn will display a shamrock, a fleur-de-lys, cartographic (small) letters A, B, C, a bell, a large circle, a treble clef, and a bass clef. Again, this assumes that the current font is a Hershey font.
You may also use Japanese syllabic characters (Hiragana and Katakana) and ideographic characters (Kanji) when drawing strings in any Hershey font. In all, 603 Kanji are available; these are the same Kanji that are available in the HersheyEUC font. The Japanese characters are indexed according to the JIS X0208 standard for Japanese typography, which represents each character by a two-byte sequence. The file `kanji.doc', which is distributed along with the GNU plotting utilities, lists the available Kanji. On most systems it is installed in `/usr/share/libplot' or `/usr/local/share/libplot'.
Each JIS X0208 character would be specified by an escape sequence which
expresses this two-byte sequence as four hexadecimal digits, such as
"\#J357e". Both bytes must be in the 0x21
...0x7e
range in order to define a JIS X0208 character. Kanji are located at
"\#J3021" and above. Characters appearing elsewhere in the JIS X0208
encoding may be accessed similarly. For example, Hiragana and Katakana
are located in the "\#J2421"..."\#J257e" range, and Roman characters
in the "\#J2321"..."\#J237e" range. The file `kana.doc', which
is installed in the same directory as `kanji.doc', lists the
encodings of the Hiragana and Katakana. For more on the JIS X0208
standard, see Ken Lunde's Understanding Japanese Information
Processing (O'Reilly, 1993), and
his on-line
supplement.
The Kanji numbering used in A. N. Nelson's Modern Reader's Japanese-English Character Dictionary, a longtime standard, is also supported. (This dictionary is published by C. E. Tuttle and Co., with ISBN 0-8048-0408-7. A revised edition [ISBN 0-8048-2036-8] appeared in 1997, but uses a different numbering.) `Nelson' escape sequences for Kanji are similar to JIS X0208 escape sequences, but use four decimal instead of four hexadecimal digits. The file `kanji.doc' gives the correspondence between the JIS numbering scheme and the Nelson numbering scheme. For example, "\#N0001" is equivalent to "\#J306c". It also gives the positions of the available Kanji in the Unicode encoding.
All available Kanji have the same width, which is the same as that of the syllabic Japanese characters (Hiragana and Katakana). Each Kanji that is not available will print as an `undefined character' glyph (a bundle of horizontal lines). The same is true for non-Kanji JIS X0208 characters that are not available.
The GNU libplot
library supports a standard set of marker
symbols, numbered 0 through 31. These are the symbols that the
graph
program will plot at each point of a dataset, if the
`-S' option is used. The list is as follows (by convention, marker
symbol #0 means no symbol at all).
The interpretation of marker symbols 1 through 5 is the same as in the well known GKS (Graphical Kernel System).
Symbols 32 and up are interpreted as characters in a certain text font.
For libplot
, it is the current font. For graph
, it
is the font selected with the `--symbol-font-name' option. By
default, this is the ZapfDingbats font except in graph -T pnm
,
graph -T gif
, graph -T pcl
, graph -T hpgl
and
graph -T tek
. These variants of graph
normally have no
access to Postscript fonts, so they use the HersheySerif font instead.
Many of the characters in the ZapfDingbats font are suitable for use as marker symbols. For example, character #74 is the Texas star. Doing
echo 0 0 1 2 2 1 3 2 4 0 | graph -T ps -m 0 -S 74 0.1 > plot.ps
will produce a Postscript plot consisting of five data points, not joined by line segments. Each data point will be marked by a Texas star, of a large font size (0.1 times the width of the plotting box).
If you are using graph -T pcl
or graph -T hpgl
and wish to
use font characters as marker symbols, you should consider using the
Wingdings font, which is available when producing PCL 5 or HP-GL/2
output. Doing
echo 0 0 1 2 2 1 3 2 4 0 | graph -T pcl -m 0 --symbol-font Wingdings -S 181 0.1 > plot.pcl
will produce a PCL 5 plot that is similar to the preceding Postscript plot. The Wingdings font has the Texas star in location #181.
Go to the first, previous, next, last section, table of contents.