Hershey {grDevices} | R Documentation |
If the family
graphical parameter (see par
)
has been set to one of the Hershey fonts (see below)
Hershey vector fonts are used to render text.
These fonts have two advantages:
For historical reasons,
when using the text
function, Hershey fonts may also be
selected via the vfont
argument, which is a character vector
of length 2 (see below for valid values).
Drawback:
You cannot use mathematical expressions (plotmath
) with
Hershey fonts.
Hershey
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)
.
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 old, vfont
specification for the text
function,
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:
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
.
\
. When R encounters a
\
, rather than drawing the \
, it treats the
subsequent character(s) as a coded description of what to draw.
One useful escape sequence (in the current context) is of the
form: \123
. The three digits following the \
specify an
octal code for a character. For example, the octal code for p
is
160 so the strings "p"
and "\160"
are equivalent. This is
useful for producing characters when there is not an appropriate key on
your keyboard.
The other useful escape sequences all begin with \\
. These are
described below.
Remember that backslashes have to be doubled in R character
strings, so they need to be entered with four backslashes.
\\ab
. For example, the escape sequence \\*a
produces a
Greek alpha. The second table in demo(Hershey)
shows all of the
symbol escape sequences and the symbols that they produce.
\\ab
are provided for producing ISO Latin-1 characters.
Another option is to use the appropriate octal code. The
(non-ASCII) ISO Latin-1 characters are in the range 241...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 in a Latin-1 or UTF-8 locale. (In the latter, non-Latin-1 characters are replaced by a dot.)
\\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.
demo(Hershey)
shows the octal codes for
the available cyrillic characters.
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 Kanji for “one” is
produced by \\#N0001
.
demo(Japanese)
shows the available Japanese characters.
\\#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.
http://www.gnu.org/software/plotutils/plotutils.html
demo(Hershey)
, par
, text
,
contour
.
Japanese
for the Japanese characters in the Hershey fonts.
Hershey ## for tables of examples, see demo(Hershey)