Go to the first, previous, next, last section, table of contents.

Text string format and escape sequences

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.

start superscript mode
end superscript mode
start subscript mode
end subscript mode
mark location
return to marked location

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.

[161] exclamdown
[162] cent
[163] sterling
[164] currency
[165] yen
[166] brokenbar
[167] section
[168] dieresis
[169] copyright
[170] ordfeminine
[171] guillemotleft
[172] logicalnot
[173] hyphen
[174] registered
[175] macron
[176] degree
[177] plusminus
[178] twosuperior
[179] threesuperior
[180] acute
[181] mu
[182] paragraph
[183] periodcentered
[184] cedilla
[185] onesuperior
[186] ordmasculine
[187] guillemotright
[188] onequarter
[189] onehalf
[190] threequarters
[191] questiondown
[192] Agrave
[193] Aacute
[194] Acircumflex
[195] Atilde
[196] Adieresis
[197] Aring
[198] AE
[199] Ccedilla
[200] Egrave
[201] Eacute
[202] Ecircumflex
[203] Edieresis
[204] Igrave
[205] Iacute
[206] Icircumflex
[207] Idieresis
[208] Eth
[209] Ntilde
[210] Ograve
[211] Oacute
[212] Ocircumflex
[213] Otilde
[214] Odieresis
[215] multiply
[216] Oslash
[217] Ugrave
[218] Uacute
[219] Ucircumflex
[220] Udieresis
[221] Yacute
[222] Thorn
[223] germandbls
[224] agrave
[225] aacute
[226] acircumflex
[227] atilde
[228] adieresis
[229] aring
[230] ae
[231] ccedilla
[232] egrave
[233] eacute
[234] ecircumflex
[235] edieresis
[236] igrave
[237] iacute
[238] icircumflex
[239] idieresis
[240] eth
[241] ntilde
[242] ograve
[243] oacute
[244] ocircumflex
[245] otilde
[246] odieresis
[247] divide
[248] oslash
[249] ugrave
[250] uacute
[251] ucircumflex
[252] udieresis
[253] yacute
[254] thorn
[255] ydieresis

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.

[0042] universal
[0044] existential
[0047] suchthat
[0052] asteriskmath
[0100] congruent
[0101] Alpha
[0102] Beta
[0103] Chi
[0104] Delta
[0105] Epsilon
[0106] Phi
[0107] Gamma
[0110] Eta
[0111] Iota
[0112] theta1
[0113] Kappa
[0114] Lambda
[0115] Mu
[0116] Nu
[0117] Omicron
[0120] Pi
[0121] Theta
[0122] Rho
[0123] Sigma
[0124] Tau
[0125] Upsilon
[0126] sigma1
[0127] Omega
[0130] Xi
[0131] Psi
[0132] Zeta
[0134] therefore
[0136] perpendicular
[0137] underline
[0140] radicalex
[0141] alpha
[0142] beta
[0143] chi
[0144] delta
[0145] epsilon
[0146] phi
[0147] gamma
[0150] eta
[0151] iota
[0152] phi1
[0153] kappa
[0154] lambda
[0155] mu
[0156] nu
[0157] omicron
[0160] pi
[0161] theta
[0162] rho
[0163] sigma
[0164] tau
[0165] upsilon
[0166] omega1
[0167] omega
[0170] xi
[0171] psi
[0172] zeta
[0176] similar
[0241] Upsilon1
[0242] minute
[0243] lessequal
[0244] fraction
[0245] infinity
[0246] florin
[0247] club
[0250] diamond
[0251] heart
[0252] spade
[0253] arrowboth
[0254] arrowleft
[0255] arrowup
[0256] arrowright
[0257] arrowdown
[0260] degree
[0261] plusminus
[0262] second
[0263] greaterequal
[0264] multiply
[0265] proportional
[0266] partialdiff
[0267] bullet
[0270] divide
[0271] notequal
[0272] equivalence
[0273] approxequal
[0274] ellipsis
[0275] arrowvertex
[0276] arrowhorizex
[0277] carriagereturn
[0300] aleph
[0301] Ifraktur
[0302] Rfraktur
[0303] weierstrass
[0304] circlemultiply
[0305] circleplus
[0306] emptyset
[0307] cap
[0310] cup
[0311] superset
[0312] reflexsuperset
[0313] notsubset
[0314] subset
[0315] reflexsubset
[0316] element
[0317] notelement
[0320] angle
[0321] nabla
[0322] registerserif
[0323] copyrightserif
[0324] trademarkserif
[0325] product
[0326] radical
[0327] dotmath
[0330] logicalnot
[0331] logicaland
[0332] logicalor
[0333] arrowdblboth
[0334] arrowdblleft
[0335] arrowdblup
[0336] arrowdblright
[0337] arrowdbldown
[0340] lozenge
[0341] angleleft
[0342] registersans
[0343] copyrightsans
[0344] trademarksans
[0345] summation
[0346] parenlefttp
[0347] parenleftex
[0350] parenleftbt
[0351] bracketlefttp
[0352] bracketleftex
[0353] bracketleftbt
[0354] bracelefttp
[0355] braceleftmid
[0356] braceleftbt
[0357] braceex
[0360] euro
[0361] angleright
[0362] integral
[0363] integraltp
[0364] integralex
[0365] integralbt
[0366] parenrighttp
[0367] parenrightex
[0370] parenrightbt
[0371] bracketrighttp
[0372] bracketrightex
[0373] bracketrightbt
[0374] bracerighttp
[0375] bracerightmid
[0376] bracerightbt

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.

[variant form of s]

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


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.

Go to the first, previous, next, last section, table of contents.