[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 4.19.7 Font object

The Font object is used for representing a font to the drawing system. You may Load fonts, and query them for specific information such as their height, the height and width of a given piece of text in that font, and more.

The following static functions are available:

`Load(font_path, size)`

  This returns a new font object. You must specify the path to the font, as well as the size of the font you wish to load. If the font cannot be found, the function will fail.

    my_font = new Font("VeraSans", 24);
    another_font = Font.Load("VeraSerif", 10);

Once you have a font object, you may use it in drawing text with a pen, or you may also query it for various bits of information.

`GetTextHeight()`

  Returns the line to line height for a font. This is useful for determining how far to increment the `y` coordinate for drawing text.

`GetLength(text, max_width)`

  Returns an integer that is an index into text, indicating the last character that should be displayed to make sure that the text is no more than `max_width` pixels wide.

`GetDimensions(text)`

  Returns a TextDimensions object indicating the width, maximum height, and descender of the given text.

    dim = my_font.GetDimensions("my text");

    Sys.Print("Dimensions of text: ", dim.width, dim.height, dim.descender);

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ]

This document was generated using texi2html 1.76.