Class Font

Inteface for fonts.

Methods

Example

main
  Font f = system.get default font
  int height = f.get height
  int ascent = f.get ascent

  print "Default font properties. Height: " & height & " Ascent: " & ascent

  string testData = "Amount of pixels needed to show this text on one line is: "
  print testData & f.get width of testData in pixels

  int screenWidth = screen.get size.get width
  int amountOfData = f.get size of testData fitting into screenWidth pixels
  print amountOfData & " characters of test data can be shown on one line."
            

See Also

System Canvas

(int) get height

Returns the height of the font in pixels.

Return value

Example

main
  Font f = system.get default font
  print "System default font height: " & f.get height
                

(int) get ascent

Returns the distance from the top of the font to the base line.

Return value

Example

main
  Font f = system.get default font
  print "System default font ascent: " & f.get ascent
                

(int) get width of <string str> in pixels

Returns the width of a string in pixels when drawn, using this font.

Parameters

Return value

Example

main
  Font f = system.get default font
  int requiredWidth = f.get width of "Test data" in pixels

  print "Required screen width in pixels to display text on one line: " & requiredWidth
                

(int) get width of <string str> range <range strRange> in pixels

Returns the width of a string in pixels when drawn, using this font.

Parameters

Return value

Exceptions

Example

main
  Font f = system.get default font
  int requiredWidth = f.get width of "Test data" range 0 size 2 in pixels

  print "Required screen width in pixels to display 2 first characters of text: " & requiredWidth
                

(int) get size of <string str> fitting into <int width> pixels

Returns the count of characters that are fully visible when String str is drawn using this font into a space that is width pixels wide.

Parameters

Return value

Exceptions

Example

main
  Font f = system.get default font
  int charactersDisplayed = f.get size of "Test data" fitting into 100 pixels

  print "Amount of characters of text fitting into 100 pixels: " & charactersDisplayed
                

(int) get size of <string str> range <Range strRange> fitting into <int width> pixels

Returns the count of characters that are fully visible when part of String str is drawn using this font into space that is width pixels wide. The sub-range is defined by the Range strRange.

Parameters

Return value

Exceptions

Example

main
  Font f = system.get default font
  int charactersDisplayed = f.get size of "Test data" range 0 size 2 fitting into 10 pixels

  print "Amount of characters of text fitting into 10 pixels: " & charactersDisplayed