grDevices (version 3.3)

Hershey: Hershey Vector Fonts in R

Description

If the family graphical parameter (see par) has been set to one of the Hershey fonts (see Details) Hershey vector fonts are used to render text.

When using the text and contour functions Hershey fonts may be selected via the vfont argument, which is a character vector of length 2 (see Details for valid values). This allows Cyrillic to be selected, which is not available via the font families.

Usage

Hershey

Arguments

Details

The Hershey fonts have two advantages:
  1. vector fonts describe each character in terms of a set of points;Rrenders the character by joining up the points with straight lines. This intimate knowledge of the outline of each character means thatRcan arbitrarily transform the characters, which can mean that the vector fonts look better for rotated text.
  2. this implementation was adapted from the GNU libplot library which provides support for non-ASCII and non-English fonts. This means that it is possible, for example, to produce weird plotting symbols and Japanese characters.
Drawback: You cannot use mathematical expressions (plotmath) with Hershey fonts.

The Hershey characters are organised into a set of fonts. A particular font is selected by specifying one of the following font families via par(family) and specifying the desired font face (plain, bold, italic, bold-italic) via par(font). ll{ family faces available "HersheySerif" plain, bold, italic, bold-italic "HersheySans" plain, bold, italic, bold-italic "HersheyScript" plain, bold "HersheyGothicEnglish" plain "HersheyGothicGerman" plain "HersheyGothicItalian" plain "HersheySymbol" plain, bold, italic, bold-italic "HersheySansSymbol" plain, italic }

In the vfont specification for the text and contour functions, the Hershey font is specified by a typeface (e.g., serif or sans serif) and a fontindex or style (e.g., plain or italic). The first element of vfont specifies the typeface and the second element specifies the fontindex. The first table produced by demo(Hershey) shows the character a produced by each of the different fonts.

The available typeface and fontindex values are available as list components of the variable Hershey. The allowed pairs for (typeface, fontindex) are: ll{ serif plain serif italic serif bold serif bold italic serif cyrillic serif oblique cyrillic serif EUC sans serif plain sans serif italic sans serif bold sans serif bold italic script plain script italic script bold gothic english plain gothic german plain gothic italian plain serif symbol plain serif symbol italic serif symbol bold serif symbol bold italic sans serif symbol plain sans serif symbol italic } and the indices of these are available as Hershey$allowed.

[object Object],[object Object],[object Object],377. For example, \366 produces the character o with an umlaut. The third table in demo(Hershey) shows all of the ISO Latin-1 escape sequences.

These characters can be used directly. (Characters not in Latin-1 are replaced by a dot.)

Several characters are missing, c-cedilla has no cedilla and sharp s (U+00DF, also known as esszett) is rendered as ss.

Special Characters:{a set of characters are provided which do not fall into any standard font. These can only be accessed by escape sequence. For example, \\LI produces the zodiac sign for Libra, and \\JU produces the astronomical sign for Jupiter. The fourth table in demo(Hershey) shows all of the special character escape sequences. }

Cyrillic Characters:{cyrillic characters are implemented according to the K018-R encoding, and can be used directly in such a locale using the Serif typeface and Cyrillic (or Oblique Cyrillic) fontindex. Alternatively they can be specified via an octal code in the range 300 to 337 for lower case characters or 340 to 377 for upper case characters. The fifth table in demo(Hershey) shows the octal codes for the available Cyrillic characters.

Cyrillic has to be selected via a ("serif", fontindex) pair rather than via a font family. }

Japanese Characters:{83 Hiragana, 86 Katakana, and 603 Kanji characters are implemented according to the EUC-JP (Extended Unix Code) encoding. Each character is identified by a unique hexadecimal code. The Hiragana characters are in the range 0x2421 to 0x2473, Katakana are in the range 0x2521 to 0x2576, and Kanji are (scattered about) in the range 0x3021 to 0x6d55.

When using the Serif typeface and EUC fontindex, these characters can be produced by a pair of octal codes. Given the hexadecimal code (e.g., 0x2421), take the first two digits and add 0x80 and do the same to the second two digits (e.g., 0x21 and 0x24 become 0xa4 and 0xa1), then convert both to octal (e.g., 0xa4 and 0xa1 become 244 and 241). For example, the first Hiragana character is produced by \244\241.

It is also possible to use the hexadecimal code directly. This works for all non-EUC fonts by specifying an escape sequence of the form \\#J1234. For example, the first Hiragana character is produced by \\#J2421.

The Kanji characters may be specified in a third way, using the so-called "Nelson Index", by specifying an escape sequence of the form \\#N1234. For example, the (obsolete) Kanji for one is produced by \\#N0001.

demo(Japanese) shows the available Japanese characters. }

Raw Hershey Glyphs:{all of the characters in the Hershey fonts are stored in a large array. Some characters are not accessible in any of the Hershey fonts. These characters can only be accessed via an escape sequence of the form \\#H1234. For example, the fleur-de-lys is produced by \\#H0746. The sixth and seventh tables of demo(Hershey) shows all of the available raw glyphs. }

References

https://www.gnu.org/software/plotutils/plotutils.html.

See Also

demo(Hershey), par, text, contour.

Japanese for the Japanese characters in the Hershey fonts.

Examples

Run this code
Hershey

## for tables of examples, see demo(Hershey)

Run the code above in your browser using DataLab