aboutsummaryrefslogtreecommitdiffstats
path: root/lib/gs/doc/src/gs_chapter5.xmlsrc
blob: fb60272598f742352a412efb3cc9c3aa8d481de9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">

<chapter>
  <header>
    <copyright>
      <year>2000</year><year>2009</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      The contents of this file are subject to the Erlang Public License,
      Version 1.1, (the "License"); you may not use this file except in
      compliance with the License. You should have received a copy of the
      Erlang Public License along with this software. If not, it can be
      retrieved online at http://www.erlang.org/.
    
      Software distributed under the License is distributed on an "AS IS"
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
      the License for the specific language governing rights and limitations
      under the License.
    
    </legalnotice>

    <title>Fonts</title>
    <prepared></prepared>
    <docno></docno>
    <date></date>
    <rev></rev>
    <file>gs_chapter5.xml</file>
  </header>

  <section>
    <title>The Font Model</title>
    <p>Text related objects can be handled with the font option <c><![CDATA[{font,Font}]]></c>. A <c><![CDATA[Font]]></c> is represented as a two or three tuple:</p>
    <list type="bulleted">
      <item><c><![CDATA[{Family,Size}]]></c></item>
      <item><c><![CDATA[{Family,Style,Size}]]></c></item>
    </list>
    <p>Examples of fonts are: <c><![CDATA[{times,12}]]></c>, <c><![CDATA[{symbol,bold,18}]]></c>, <c><![CDATA[{courier,[bold,italic],6}]]></c>, <c><![CDATA[{screen,12}]]></c>.</p>
    <p>The most important requirement with the font model is to ensure that there is always a "best possible" font present. For example, if an application tries to use the font <c><![CDATA[{times,17}]]></c> on a computer system which does not have this font available, the <c><![CDATA[gs]]></c> font model automatically substitutes <c><![CDATA[{times,16}]]></c>.</p>
    <p>Note that GS requires that the following fonts are available if using an X-server display:</p>
    <list type="bulleted">
      <item>fixed</item>
      <item>-*-courier-*</item>
      <item>-*-times-*</item>
      <item>-*-helvetica-*</item>
      <item>-*-symbol-*</item>
      <item>"-*-new century schoolbook-"</item>
      <item>-*-screen-*</item>
    </list>
    <p>To find out which font is actually chosen by the <c><![CDATA[gs]]></c>, use the option <c><![CDATA[{choose_font,Font}]]></c>. For example, the following situation might occur:</p>
    <pre><![CDATA[
1> <input>G=gs:start().</input>
{1,<0.20.0>}
2><input>gs:read(G,{choose_font,{times,38}}).</input>
{times,[],38}
3> <input>gs:read(G,{choose_font,{screen,italic,6}}).</input> 
{courier,italic,6}
4> 
    ]]></pre>
    <p>When programming with fonts, it is often necessary to find the size of a string which uses a specific font. <c><![CDATA[{font_wh,Font}]]></c> returns the width and height of any string and any font. The following example illustrates its usage:</p>
    <marker id="gs_fig6"></marker>
    <image file="images/ex15.gif">
      <icaption>Font Examples</icaption>
    </image>
    <codeinclude file="examples/ex15.erl" tag="" type="erl"></codeinclude>
  </section>
</chapter>