Sophie

Sophie

distrib > Fedora > 18 > x86_64 > media > updates > by-pkgid > 86de73cd0961932e7aca64f21352ffa6 > files > 49

grads-2.0.2-1.fc18.x86_64.rpm

<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.--><title>Font Control</title>

<style type="text/css">
<!--
body {
	background-color: #e0f0ff;
}
.style1 {color: #990000}
-->
</style>
<H2><B> Font Control</B> in GrADS</H2>
<p><a href="#hershey">Hershey Fonts</a><br />
  <a href="#cairo">Cairo Fonts</a><br />
<a href="#size">Controlling Font Size</a><br />
<a href="#overrides">Temporary Overrides</a><br />
  <a href="#examples">Examples</a></H2>
<H3><a name="hershey" id="hershey"></a>Hershey Fonts</H3>
<P>GrADS has traditionally used the Hershey vector fonts for all text displays. The Hershey  fonts are drawn as a collection of line segments, and can be rotated or scaled (stretched) in the X or Y direction; this makes them extremely flexible for different applications in GrADS. The Hershey fonts are defined in a set of <a href="font.html">font files</a>, which are part of the GrADS distribution and should be stored in a directory named by the <a href="http://iges.org/grads/gadoc/gradcomdgrads.html#env">GADDIR</a> environment variable. The  font style is controlled with the <code><a href="gradcomdsetfont.html">set font</a></code> command. Font numbers 0-5 are provided by GrADS (definitions given below); numbers 6-9 are reserved for additional user-defined Hershey font files. The script <a href="ftp://iges.org/grads/scripts/font.gs">font.gs</a> will display all the characters in a given font set. 
<pre>
font 0 -- Simplex Roman 
font 1 -- Complex Roman
font 2 -- Complex Italic
font 3 -- Complex Greek
font 4 -- Duplex Roman
font 5 -- Triplex Roman
</pre>
<H3><a name="cairo" id="cairo"></a>Cairo Fonts</H3>
<P>Beginning with <span class="style1">GrADS version 2.1.a0</span>, additional fonts are available with the Cairo graphics library. GrADS employs Cairo's &quot;toy&quot; font API; it is simpler to implement, fast, and  meets GrADS's needs for drawing text. Cairo uses the freetype2 font library, which supports a number of scalable font formats including TrueType, Type 1, OpenType, X11 PCF, and Windows FNT. Whether GrADS will support all these font types depends on if they are available on your particular system. On macintosh OSX systems, available fonts are generally in two directories: <code>/Library/Fonts</code> and <code>/System/Library/Fonts/</code>. On unix systems, look in <code>/usr/share/fonts/</code> and <code>/usr/share/X11/fonts/</code>. Unfortunately, with the &quot;toy&quot; API, there is no way to list available font family names. Three generic family names are built-in as GrADS defaults: sans-serif, serif, and monospace. These three pre-defined default fonts correspond to font numbers 10-12. Font numbers 13-99 are reserved for user-defined font names, which are specified with the <a href="gradcomdsetfontdef.html"><code>set fontdef</code></a> command. If the user-defined font family is not available, then the display defaults to font 10 (sans-serif) .

If your build of GrADS is not enabled with the Cairo graphics library, you will get an error message if you use  <code><a href="gradcomdsetfont.html">set font</a></code> to try to set a font number greater than 9.
<h3><a name="size" id="size"></a>Controlling Font Size</h3> 
<p>The <code><a href="gradcomdsetstrsiz.html">set strsiz</a></code> command controls the font size for Hershey and Cairo fonts. Because the Hershey fonts are vector-based, you can give different scaling factors for the width and height of the letters and the font will stretch accordingly. For Cairo fonts, only one scaling factor (the vertical size) is appropriate -- the fonts do not deform in the X or Y dimension, they simply get bigger or smaller. If the vertical size is not given with <code><a href="gradcomdsetstrsiz.html">set strsiz</a></code>, the horizontal size will be used instead. </p>
<h3><a name="overrides" id="overrides"></a>Temporary Overrides</h3>
<P>Hershey fonts correspond to single-digit font numbers; Cairo fonts correspond to double-digit font numbers. When you invoke the <code><a href="gradcomdsetfont.html">set font</a></code> command and the font number is between 0 and 9, you are in <em>hershey mode</em>. If the font number is between 10 and 99, you are in <em>cairo mode</em>. 
Hershey and Cairo fonts cannot be mixed together in the same string. 
<P><em><strong>Font Override: </strong></em><br />
  To temporarily override the  font  in a string of text, use the back quote character (`). When you are in <em>hershey mode</em>, a back quote followed by a single digit selects that font number for the remainder of the string. When you are in <em>cairo mode</em>, a back quote followed by 'f' and a double-digit number selects that font number for the remainder of the string. See examples below.
<P><em><strong>Text Position Override:</strong></em><br />
  It is also possible to use the back quote to change the position of the text, to draw a string above or below the base line for subscripts or superscripts. A back quote followed by the letter a (`a) will draw the subsequent text in the string as a superscript (above normal). A back quote followed by the letter b (`b) will draw the subsequent text in the string as a subscript (below normal). A back quote followed by the letter n (`n) will draw the subsequent text in the string in a normal position, to undo the effects of `a or `b. The use of the back quote to override the font works with the draw string command, contour labels, titles, axis labels, etc. The text position overrides `a, `b, and `n work in both <em>hershey mode</em> and <em>cairo mode</em>. 
<P><em><strong>Degree Symbol:</strong></em><br />
If you are in <em>hershey mode</em>, you can draw a degree symbol by drawing a period with font number 3 (`3.) If you are in <em>cairo mode</em>, you can draw a degree symbol with a backquote followed by the letter d (`d). See examples below. 
<H3><a name="examples" id="examples"></a>Examples</H3>
<pre>Hershey Mode:
set font 0
draw string 1.5 1.25 `1use font 2 to `2emphasize `1a particular word
draw string 1.5 2.25 use font 3 for `3greek `0letters
draw string 1.5 3.25 `3p`0r`a2`n = area of a circle
draw string 1.5 4.25 label temperatures in `3.`0C or `3.`0F


Cairo Mode:
set font 10
draw string 1.5 1.25 use font 11 for `f11serif`f10 and font 12 for `f12monospace
set fontdef 13 symbol
draw string 1.5 2.25 use symbol font for `f13greek`f10 letters

draw string 1.5 4.25 label temperatures in `dC or `dF</pre>