Rev 25118 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
%% NB: Microsoft Help Compiler often crashes on this file%% Do not alter unless you have checked on Windows!\name{Hershey}\alias{Hershey}\title{Hershey Vector Fonts in R}\usage{Hershey}\description{If the \code{vfont} argument to one of the text-drawing functions(\code{\link{text}}, \code{\link{mtext}}, \code{\link{title}},\code{\link{axis}}, and \code{\link{contour}}) is a character vectorof length 2, Hershey vector fonts are used to render the text.These 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 and 3d 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.}\details{The Hershey characters are organised into a set of fonts, which arespecified by a typeface (e.g., \code{serif} or \code{sans serif})and a fontindex or \dQuote{style} (e.g., \code{plain} or \code{italic}).The first element of \code{vfont} specifies the typeface and the secondelement specifies the fontindex. The first tableproduced by \code{demo(Hershey)} shows the character \code{a} producedby each of the 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 \code{\\}. When \R encounters a\code{\\}, rather than drawing the \code{\\}, it treats thesubsequent character(s) as a coded description of what to draw.One useful escape sequence (in the current context) is of theform: \code{\\123}. The three digits following the \code{\\} specify anoctal code for a character. For example, the octal code for \code{p} is160 so the strings \code{"p"} and \code{"\\160"} are equivalent. This isuseful for producing characters when there is not an appropriate key onyour keyboard.The other useful escape sequences all begin with \code{\\\\}. These aredescribed below.Remember that backslashes have to be doubled in \R characterstrings, so they need to be entered with \emph{four} backslashes.}\item{Symbols:}{an entire string of Greek symbols can be produced byselecting the Serif Symbol or Sans Serif Symbol typeface. To allowGreek symbols to be embedded in a string which uses a non-symboltypeface, there are a set of symbol escape sequences of the form\code{\\\\ab}. For example, the escape sequence \code{\\\\*a} produces aGreek alpha. The second table in \code{demo(Hershey)} shows all of thesymbol escape sequences and the symbols that they produce.}\item{ISO Latin-1:}{further escape sequences of the form \code{\\\\ab} areprovided for producing ISO Latin-1 characters (for example, ifyou only have a US keyboard). Another option is to use the appropriateoctal code. The (non-ASCII) ISO Latin-1 characters are in the range241\dots377. For example, \code{\\366} produces the character \code{o}with an umlaut. The third table in \code{demo(Hershey)} shows allof the ISO Latin-1 escape sequences.}\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, \code{\\\\LI} produces the zodiac sign forLibra, and \code{\\\\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. On a US keyboard, these can beproduced using the Serif typeface and Cyrillic (or Oblique Cyrillic)fontindex and specifying an octal code in the range 300 to 337 forlower case characters or 340 to 377 for upper case characters.The fifth table in \code{demo(Hershey)} shows the octal codes forthe available cyrillic characters.}\item{Japanese Characters:}{83 Hiragana, 86 Katakana, and 603 Kanjicharacters are implemented according to the EUC (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 \code{\\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\code{\\\\#J1234}. For example, the first Hiragana character is producedby \code{\\\\#J2421}.The Kanji characters may be specified in a third way, using theso-called "Nelson Index", by specifying an escape sequence of the form\code{\\\\#N1234}. For example, the Kanji for \dQuote{one} isproduced by \code{\\\\#N0001}.\code{demo(Japanese)} shows the available Japanese characters.}\item{Raw Hershey Glyphs:}{all of the characters in the Hershey fontsare stored in a large array. Some characters are not accessible inany of the Hershey fonts. These characters can only be accessed viaan escape sequence of the form \code{\\\\#H1234}. For example, thefleur-de-lys is produced by \code{\\\\#H0746}. The sixth and seventhtables of \code{demo(Hershey)} shows all of the available rawglyphs.}}}\references{\url{http://www.gnu.org/software/plotutils/plotutils.html}}\seealso{\code{demo(Hershey)}, \code{\link{text}}, \code{\link{contour}}.\code{\link{Japanese}} for the Japanese characters in the Hershey fonts.}\examples{str(Hershey)## for tables of examples, see demo(Hershey)}\keyword{aplot}