Font

From Spheriki

Jump to: navigation, search

A Sphere Font object contains the images that control how letters, numbers and symbols appear. You can use fonts to make text look like you want it to.

Fonts are typically created or generated by the Sphere editor, as files ending with '.rfn'.


Contents

Initializers


Methods


Members

None.


Examples

For this example, use the Sphere editor's Import Font option to create a font for this example. Name it 'bleh.rfn'.

var my_font = LoadFont("bleh.rfn");
var their_font = GetSystemFont();

function game()
{
  var y = 0;
  
  my_font.drawText(0, y, "This is the first line.");
  y += my_font.getHeight();
  
  their_font.drawText(0, y, "The second line!");
  y += their_font.getHeight();
  
  my_font.drawTextBox(
      0, y, 64, my_font.getHeight() * 3,
      0,
      "This bit is rather long, but if I'm right, it should wrap." );
  y += my_font.getHeight() * 3;
  
  their_font.drawText(0, y, "Final line! At last!");
  
  FlipScreen();
  GetKey();
}


Notes

  • Like all drawing functions, you will need to call FlipScreen() before the results of drawing text with a font will appear.
  • Font.drawTextBox() can accept special characters such as newlines. Font.drawText() will not, and instead draws the characters from the font. See the relevant function pages for more details.

See also

Personal tools