Font.drawText

From Spheriki

Jump to: navigation, search

Draws text at the given screen coordinates with the font.


Contents

Usage

Font.drawText(x, y, text);
  • Font Sphere Font object. The font to draw the text with.
  • x Number. The x coordinate of the top-left corner of the text to draw.
  • y Number. The y coordinate of the top-left corner of the text to draw.
  • text String. The text to be drawn.


Examples

var f = GetSystemFont();
f.drawText(50, 100, "Gotcha!");
FlipScreen();
GetKey();

This simple example loads the default system font, and uses it to draw the text "Gotcha!" at the screen coordinates (50, 100). Sphere then waits for a key press before continuing.

Many examples in this documentation use this function to display text.


Notes

  • The function is generally not called literally with the identifier Font.drawText(x, y, text). Rather, drawText() is a method of the Sphere Font object that is loaded, either by GetSystemFont() or LoadFont().
  • All of the supplied text will be displayed on a single line. The output is guaranteed to be restricted within the height of the font glyphs.
  • Escape sequences, such as \n for newline and \t for tab, are not processed. See the next tip.
  • For word wrapping of text and escape code processing, see Font.drawTextBox(). More methods of outputting text using a font can be found in the Sphere Font object page.


See also

Personal tools