Legacy:Font/drawTextBox: Difference between revisions

From Spherical
Jump to navigation Jump to search
Created page with "Draw (write) several lines of text on the screen within the indicated area, using the specified font. __TOC__ ==Usage== {{Usage|object=Font|func=drawTextBox|params=x, y, wid..."
 
→Examples: Fix typo
Line 18: Line 18:
<syntaxhighlight>
<syntaxhighlight>
var font = GetSystemFont();
var font = GetSystemFont();
font.drawtextBox(10, 10, 300, 220, 0, "I am a line of text.\nI am another line of text.");
font.drawTextBox(10, 10, 300, 220, 0, "I am a line of text.\nI am another line of text.");


FlipScreen();
FlipScreen();

Revision as of 11:51, 23 June 2013

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