LoadFont

From Spheriki

Jump to: navigation, search

Loads a Sphere font from a file.


Contents

Usage

Font LoadFont(filename);
  • filename String. Filename of the font to load, relative to the 'fonts' subdirectory.


Examples

var f = LoadFont("myfont.rfn");
f.drawText(100, 80, "This text is drawn with a font.");
FlipScreen();
GetKey();

The above example will show the text using the font 'myfont.rfn', inside the game's 'fonts' subdirectory. The font file must exist first.


Notes

  • To load fonts in subdirectories other than 'fonts', use one of the following prefixes, followed by the desired path:
    • '~/' to load from the game's base directory. This allows for better organisation.
    • '/common/' to load from 'Sphere/common/', a directory that can be shared by all games.
  • If text needs to be displayed, but the font style isn't important, consider the alternative function GetSystemFont().

See also

  • Sphere Font object
Personal tools