20002009 Ericsson AB. All Rights Reserved. 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. Fonts gs_chapter5.xml
The Font Model

Text related objects can be handled with the font option . A is represented as a two or three tuple:

Examples of fonts are: , , , .

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 on a computer system which does not have this font available, the font model automatically substitutes .

Note that GS requires that the following fonts are available if using an X-server display:

fixed -*-courier-* -*-times-* -*-helvetica-* -*-symbol-* "-*-new century schoolbook-" -*-screen-*

To find out which font is actually chosen by the , use the option . For example, the following situation might occur:

 G=gs:start().
{1,<0.20.0>}
2>gs:read(G,{choose_font,{times,38}}).
{times,[],38}
3> gs:read(G,{choose_font,{screen,italic,6}}). 
{courier,italic,6}
4> 
    ]]>

When programming with fonts, it is often necessary to find the size of a string which uses a specific font. returns the width and height of any string and any font. The following example illustrates its usage:

Font Examples