Rev 52336 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/grDevices/man/Hershey.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2010 R Core Development Team% Distributed under GPL 2 or later\name{Hershey}\alias{Hershey}\title{Hershey Vector Fonts in R}\description{If the \code{family} graphical parameter (see \code{\link{par}})has been set to one of the Hershey fonts (see \sQuote{Details})Hershey vector fonts are used to render text.When using the \code{\link{text}} and \code{\link{contour}} functionsHershey fonts may be selected via the \code{vfont} argument, which isa character vector of length 2 (see \sQuote{Details} for validvalues). This allows Cyrillic to be selected, which is not availablevia the font families.}\usage{Hershey}\details{The Hershey fonts have two advantages:\cr\enumerate{\item vector fonts describe eachcharacter in terms of a set of points; \R renders the character byjoining up the points with straight lines. This intimate knowledge ofthe outline of each character means that \R can arbitrarily transformthe characters, which can mean that the vector fonts look betterfor rotated text.\item this implementation was adapted from the GNU libplot librarywhich provides support for non-ASCII and non-English fonts. This meansthat it is possible, for example, to produce weird plotting symbols andJapanese characters.}Drawback:\crYou cannot use mathematical expressions (\code{\link{plotmath}}) withHershey fonts.The Hershey characters are organised into a set of fonts. Aparticular font is selected by specifying one of the followingfont families via \code{par(family)} and specifying the desired fontface (plain, bold, italic, bold-italic) via \code{par(font)}.%% The basic "table" is in ../../../main/engine.c\tabular{ll}{family \tab faces available \cr\code{"HersheySerif"} \tab plain, bold, italic, bold-italic \cr\code{"HersheySans"} \tab plain, bold, italic, bold-italic \cr\code{"HersheyScript"} \tab plain, bold \cr\code{"HersheyGothicEnglish"} \tab plain \cr\code{"HersheyGothicGerman"} \tab plain \cr\code{"HersheyGothicItalian"} \tab plain \cr\code{"HersheySymbol"} \tab plain, bold, italic, bold-italic \cr\code{"HersheySansSymbol"} \tab plain, italic \cr}In the \code{vfont} specification for the \code{text} and\code{contour} functions, the Hershey font is specified by a typeface(e.g., \code{serif} or \code{sans serif}) and a fontindex or\sQuote{style} (e.g., \code{plain} or \code{italic}). The firstelement of \code{vfont} specifies the typeface and the second elementspecifies the fontindex. The first table produced by\code{demo(Hershey)} shows the character \code{a} produced by each ofthe different fonts.The available \code{typeface} and \code{fontindex} values areavailable as list components of the variable \code{Hershey}.The allowed pairs for \code{(typeface, fontindex)} are:%% This is checked (via max{#}) in FixupVFont() ../../../main/plot.c%% The basic "table" really is in ../../../modules/vfonts/g_fontdb.c\tabular{ll}{serif \tab plain \crserif \tab italic \crserif \tab bold \crserif \tab bold italic \crserif \tab cyrillic \crserif \tab oblique cyrillic \crserif \tab EUC \crsans serif \tab plain \crsans serif \tab italic \crsans serif \tab bold \crsans serif \tab bold italic \crscript \tab plain \crscript \tab italic \crscript \tab bold \crgothic english \tab plain \crgothic german \tab plain \crgothic italian \tab plain \crserif symbol \tab plain \crserif symbol \tab italic \crserif symbol \tab bold \crserif symbol \tab bold italic \crsans serif symbol \tab plain \crsans serif symbol \tab italic \cr}and the indices of these are available as \code{Hershey$allowed}.\describe{\item{Escape sequences:}{The string to be drawn can include escapesequences, which all begin with a \samp{\\}. When \R encounters a\samp{\\}, rather than drawing the \samp{\\}, it treats thesubsequent character(s) as a coded description of what to draw.One useful escape sequence (in the current context) is of theform: \samp{\\123}. The three digits following the \samp{\\}specify an octal code for a character. For example, the octalcode for \code{p} is 160 so the strings \code{"p"} and\code{"\\160"} are equivalent. This is useful for producingcharacters when there is not an appropriate key on your keyboard.The other useful escape sequences all begin with \samp{\\\\}.These are described below. Remember that backslashes have to bedoubled in \R character strings, so they need to be entered with\emph{four} backslashes.}\item{Symbols:}{an entire string of Greek symbols can be produced byselecting the HersheySymbol or HersheySansSymbol family or theSerif Symbol or Sans Serif Symbol typeface. To allow Greeksymbols to be embedded in a string which uses a non-symboltypeface, there are a set of symbol escape sequences of the form\samp{\\\\ab}. For example, the escape sequence \samp{\\\\*a}produces a Greek alpha. The second table in \code{demo(Hershey)}shows all of the symbol escape sequences and the symbols that theyproduce.}\item{ISO Latin-1:}{further escape sequences of the form\samp{\\\\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\dots{}377.For example, \samp{\\366} produces the character o with an umlaut.The third table in \code{demo(Hershey)} shows all of the ISOLatin-1 escape sequences.These characters can be used directly. (Characters not in Latin-1are replaced by a dot.)Several characters are missing, c-cedilla has no cedilla and\sQuote{sharp s} (\samp{U+00DF}, also known as \sQuote{esszett})is rendered as \code{ss}.}\item{Special Characters:}{a set of characters are provided whichdo not fall into any standard font. These can only be accessed byescape sequence. For example, \samp{\\\\LI} produces the zodiac sign forLibra, and \samp{\\\\JU} produces the astronomical sign for Jupiter.The fourth table in \code{demo(Hershey)} shows all of thespecial character escape sequences.}\item{Cyrillic Characters:}{cyrillic characters are implementedaccording to the K018-R encoding, and can be used directly in sucha locale using the Serif typeface and Cyrillic (or Oblique Cyrillic)fontindex. Alternatively they can be specified via an octal codein the range 300 to 337 for lower case characters or 340 to 377 forupper case characters. The fifth table in \code{demo(Hershey)} shows theoctal codes for the available Cyrillic characters.Cyrillic has to be selected via a \code{("serif", fontindex)} pairrather than via a font family.}\item{Japanese Characters:}{83 Hiragana, 86 Katakana, and 603 Kanjicharacters are implemented according to the EUC-JP (Extended Unix Code)encoding. Each character is identified by a unique hexadecimal code.The Hiragana charactersare in the range 0x2421 to 0x2473, Katakana are in the range 0x2521 to0x2576, and Kanji are (scattered about) in the range 0x3021 to 0x6d55.When using the Serif typeface and EUCfontindex, these characters can be produced by a \emph{pair} of octalcodes. Given the hexadecimal code (e.g., 0x2421), take the first twodigits 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 Hiraganacharacter is produced by \samp{\\244\\241}.It is also possible to use the hexadecimal code directly. This worksfor all non-EUC fonts by specifying an escape sequence of the form\samp{\\\\#J1234}. For example, the first Hiragana character is producedby \samp{\\\\#J2421}.The Kanji characters may be specified in a third way, using theso-called "Nelson Index", by specifying an escape sequence of the form\samp{\\\\#N1234}. For example, the (obsolete) Kanji for \sQuote{one} isproduced by \samp{\\\\#N0001}.\code{demo(Japanese)} shows the available Japanese characters.}\item{Raw Hershey Glyphs:}{all of the characters in the Hersheyfonts are stored in a large array. Some characters are notaccessible in any of the Hershey fonts. These characters can onlybe accessed via an escape sequence of the form \samp{\\\\#H1234}.For example, the fleur-de-lys is produced by \samp{\\\\#H0746}.The sixth and seventh tables of \code{demo(Hershey)} shows all ofthe available raw glyphs. } } } \references{\url{http://www.gnu.org/software/plotutils/plotutils.html} }\seealso{ \code{\link{demo}(Hershey)}, \code{\link{par}},\code{\link{text}}, \code{\link{contour}}.\code{\link{Japanese}} for the Japanese characters in the Hershey fonts.}\examples{Hershey## for tables of examples, see demo(Hershey)}\keyword{aplot}