20002016 Ericsson AB. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 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