EVOLUTION-MANAGER
Edit File: Hershey.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Hershey Vector Fonts in R</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for Hershey {grDevices}"><tr><td>Hershey {grDevices}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Hershey Vector Fonts in R</h2> <h3>Description</h3> <p>If the <code>family</code> graphical parameter (see <code><a href="../../graphics/html/par.html">par</a></code>) has been set to one of the Hershey fonts (see ‘Details’) Hershey vector fonts are used to render text. </p> <p>When using the <code><a href="../../graphics/html/text.html">text</a></code> and <code><a href="../../graphics/html/contour.html">contour</a></code> functions Hershey fonts may be selected via the <code>vfont</code> 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. </p> <h3>Usage</h3> <pre> Hershey </pre> <h3>Details</h3> <p>The Hershey fonts have two advantages:<br /> </p> <ol> <li><p> vector fonts describe each character in terms of a set of points; <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> renders the character by joining up the points with straight lines. This intimate knowledge of the outline of each character means that <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> can arbitrarily transform the characters, which can mean that the vector fonts look better for rotated text. </p> </li> <li><p> 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. </p> </li></ol> <p>Drawback:<br /> You cannot use mathematical expressions (<code><a href="plotmath.html">plotmath</a></code>) with Hershey fonts. </p> <p>The Hershey characters are organised into a set of fonts. A particular font is selected by specifying one of the following font families via <code>par(family)</code> and specifying the desired font face (plain, bold, italic, bold-italic) via <code>par(font)</code>. </p> <table summary="Rd table"> <tr> <td style="text-align: left;"> family </td><td style="text-align: left;"> faces available </td> </tr> <tr> <td style="text-align: left;"> <code>"HersheySerif"</code> </td><td style="text-align: left;"> plain, bold, italic, bold-italic </td> </tr> <tr> <td style="text-align: left;"> <code>"HersheySans"</code> </td><td style="text-align: left;"> plain, bold, italic, bold-italic </td> </tr> <tr> <td style="text-align: left;"> <code>"HersheyScript"</code> </td><td style="text-align: left;"> plain, bold </td> </tr> <tr> <td style="text-align: left;"> <code>"HersheyGothicEnglish"</code> </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> <code>"HersheyGothicGerman"</code> </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> <code>"HersheyGothicItalian"</code> </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> <code>"HersheySymbol"</code> </td><td style="text-align: left;"> plain, bold, italic, bold-italic </td> </tr> <tr> <td style="text-align: left;"> <code>"HersheySansSymbol"</code> </td><td style="text-align: left;"> plain, italic </td> </tr> <tr> <td style="text-align: left;"> </td> </tr> </table> <p>In the <code>vfont</code> specification for the <code>text</code> and <code>contour</code> functions, the Hershey font is specified by a typeface (e.g., <code>serif</code> or <code>sans serif</code>) and a fontindex or ‘style’ (e.g., <code>plain</code> or <code>italic</code>). The first element of <code>vfont</code> specifies the typeface and the second element specifies the fontindex. The first table produced by <code>demo(Hershey)</code> shows the character <code>a</code> produced by each of the different fonts. </p> <p>The available <code>typeface</code> and <code>fontindex</code> values are available as list components of the variable <code>Hershey</code>. The allowed pairs for <code>(typeface, fontindex)</code> are: </p> <table summary="Rd table"> <tr> <td style="text-align: left;"> serif </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> serif </td><td style="text-align: left;"> italic </td> </tr> <tr> <td style="text-align: left;"> serif </td><td style="text-align: left;"> bold </td> </tr> <tr> <td style="text-align: left;"> serif </td><td style="text-align: left;"> bold italic </td> </tr> <tr> <td style="text-align: left;"> serif </td><td style="text-align: left;"> cyrillic </td> </tr> <tr> <td style="text-align: left;"> serif </td><td style="text-align: left;"> oblique cyrillic </td> </tr> <tr> <td style="text-align: left;"> serif </td><td style="text-align: left;"> EUC </td> </tr> <tr> <td style="text-align: left;"> sans serif </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> sans serif </td><td style="text-align: left;"> italic </td> </tr> <tr> <td style="text-align: left;"> sans serif </td><td style="text-align: left;"> bold </td> </tr> <tr> <td style="text-align: left;"> sans serif </td><td style="text-align: left;"> bold italic </td> </tr> <tr> <td style="text-align: left;"> script </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> script </td><td style="text-align: left;"> italic </td> </tr> <tr> <td style="text-align: left;"> script </td><td style="text-align: left;"> bold </td> </tr> <tr> <td style="text-align: left;"> gothic english </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> gothic german </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> gothic italian </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> serif symbol </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> serif symbol </td><td style="text-align: left;"> italic </td> </tr> <tr> <td style="text-align: left;"> serif symbol </td><td style="text-align: left;"> bold </td> </tr> <tr> <td style="text-align: left;"> serif symbol </td><td style="text-align: left;"> bold italic </td> </tr> <tr> <td style="text-align: left;"> sans serif symbol </td><td style="text-align: left;"> plain </td> </tr> <tr> <td style="text-align: left;"> sans serif symbol </td><td style="text-align: left;"> italic </td> </tr> <tr> <td style="text-align: left;"> </td> </tr> </table> <p>and the indices of these are available as <code>Hershey$allowed</code>. </p> <dl> <dt>Escape sequences:</dt><dd><p>The string to be drawn can include escape sequences, which all begin with a <span class="samp">\</span>. When <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> encounters a <span class="samp">\</span>, rather than drawing the <span class="samp">\</span>, it treats the subsequent character(s) as a coded description of what to draw. </p> <p>One useful escape sequence (in the current context) is of the form: <span class="samp">\123</span>. The three digits following the <span class="samp">\</span> specify an octal code for a character. For example, the octal code for <code>p</code> is 160 so the strings <code>"p"</code> and <code>"\160"</code> are equivalent. This is useful for producing characters when there is not an appropriate key on your keyboard. </p> <p>The other useful escape sequences all begin with <span class="samp">\\</span>. These are described below. Remember that backslashes have to be doubled in <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> character strings, so they need to be entered with <em>four</em> backslashes. </p> </dd> <dt>Symbols:</dt><dd><p>an entire string of Greek symbols can be produced by selecting the HersheySymbol or HersheySansSymbol family or the Serif Symbol or Sans Serif Symbol typeface. To allow Greek symbols to be embedded in a string which uses a non-symbol typeface, there are a set of symbol escape sequences of the form <span class="samp">\\ab</span>. For example, the escape sequence <span class="samp">\\*a</span> produces a Greek alpha. The second table in <code>demo(Hershey)</code> shows all of the symbol escape sequences and the symbols that they produce. </p> </dd> <dt>ISO Latin-1:</dt><dd><p>further escape sequences of the form <span class="samp">\\ab</span> 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, <span class="samp">\366</span> produces the character o with an umlaut. The third table in <code>demo(Hershey)</code> shows all of the ISO Latin-1 escape sequences. </p> <p>These characters can be used directly. (Characters not in Latin-1 are replaced by a dot.) </p> <p>Several characters are missing, c-cedilla has no cedilla and ‘sharp s’ (<span class="samp">U+00DF</span>, also known as ‘esszett’) is rendered as <code>ss</code>. </p> </dd> <dt>Special Characters:</dt><dd><p>a set of characters are provided which do not fall into any standard font. These can only be accessed by escape sequence. For example, <span class="samp">\\LI</span> produces the zodiac sign for Libra, and <span class="samp">\\JU</span> produces the astronomical sign for Jupiter. The fourth table in <code>demo(Hershey)</code> shows all of the special character escape sequences. </p> </dd> <dt>Cyrillic Characters:</dt><dd><p>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 <code>demo(Hershey)</code> shows the octal codes for the available Cyrillic characters. </p> <p>Cyrillic has to be selected via a <code>("serif", fontindex)</code> pair rather than via a font family. </p> </dd> <dt>Japanese Characters:</dt><dd><p>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. </p> <p>When using the Serif typeface and EUC fontindex, these characters can be produced by a <em>pair</em> 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 <span class="samp">\244\241</span>. </p> <p>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 <span class="samp">\\#J1234</span>. For example, the first Hiragana character is produced by <span class="samp">\\#J2421</span>. </p> <p>The Kanji characters may be specified in a third way, using the so-called "Nelson Index", by specifying an escape sequence of the form <span class="samp">\\#N1234</span>. For example, the (obsolete) Kanji for ‘one’ is produced by <span class="samp">\\#N0001</span>. </p> <p><code>demo(Japanese)</code> shows the available Japanese characters. </p> </dd> <dt>Raw Hershey Glyphs:</dt><dd><p>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 <span class="samp">\\#H1234</span>. For example, the fleur-de-lys is produced by <span class="samp">\\#H0746</span>. The sixth and seventh tables of <code>demo(Hershey)</code> shows all of the available raw glyphs. </p> </dd> </dl> <h3>References</h3> <p><a href="https://www.gnu.org/software/plotutils/plotutils.html">https://www.gnu.org/software/plotutils/plotutils.html</a>. </p> <h3>See Also</h3> <p><code><a href="../../utils/html/demo.html">demo</a>(Hershey)</code>, <code><a href="../../graphics/html/par.html">par</a></code>, <code><a href="../../graphics/html/text.html">text</a></code>, <code><a href="../../graphics/html/contour.html">contour</a></code>. </p> <p><code><a href="Japanese.html">Japanese</a></code> for the Japanese characters in the Hershey fonts. </p> <h3>Examples</h3> <pre> Hershey ## for tables of examples, see demo(Hershey) </pre> <hr /><div style="text-align: center;">[Package <em>grDevices</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>