Legacy:Font/drawTextBox

From Spherical
< Legacy:Font
Revision as of 11:51, 23 June 2013 by DaVince (talk | contribs) (Examples: Fix typo)
Jump to: navigation, search

Draw (write) several lines of text on the screen within the indicated area, using the specified font.

Usage

Font.drawTextBox(x, y, width, height, offset, text);


  • x Integer. The x position on the screen where the text starts drawing.
  • y Integer. The y position of the text on the screen.
  • width Integer. The width of the area to display the text in. Overflowing text goes to the next line.
  • height Integer. The height of the area to display the text in. Any vertically overflowing text is not displayed.
  • offset Integer. The amount of pixels to horizontally offset the the text on the first line by.
  • text String. The text to display.

Examples

var font = GetSystemFont();
font.drawTextBox(10, 10, 300, 220, 0, "I am a line of text.\nI am another line of text.");

FlipScreen();
GetKey();

//Load the font to use
//Draw two lines of text (delimited by a \n), with an area size of 300x220 and no offset

//Now display it on the screen
//Now wait for user interaction

Notes

  • When wrapping text to the next line. It will try to split by word, so there are no strange word cutoffs.
  • Use \n to jump to the next line.
  • Use \t to add tab space. Note that Sphere just inserts a fixed amount of blank space, so it's not lines up with any other tabs you use (unless they're all on new lines).

See also