FONT()

From Liberty BASIC Family
Jump to navigation Jump to search
Not supported in Just BASIC Not supported in Liberty BASIC Not supported in Liberty BASIC 5 Supported in Run BASIC

Description

Specify the font used to display text in a graphics area

Syntax

  1. #handle FONT("fontname", pointSize [,"bold"][, "italic"]) - Specify a font by name and size to use for drawing text. Italic and bold are optional

Hints

Text is displayed in a graphic object by starting the text string with a backslash character. It is located with its lower left corner at the current pen position. Note that this is position 0,0 by default, so the pen must be moved to within the graphic area for the text to be visible. Each backslash character forces a new line in the text.
Text can be displayed in the font face and size and attributes of your choosing. You can issue multiple font statements, so text can appear in more than one font face in a single graphic object. The FONT() method requires a font face name as a string, and a point size as a number. Adding commas and either "bold", "italic" or both will add those attributes to the font. If the font face name is not recognized, a default font face will be used.

Example

Simple demo that prints some text in a graphic object:

'create a graphic object
graphic #g, 600,400

'place the drawing pen
#g place(20,200)

'print text 
#g "\Hello, World!"

'display on web page
render #g

Demo of new lines in graphic text:

'create a graphic object
graphic #g, 600,400

'place the drawing pen
#g place(20,40)

'print text 
#g "\Hello, World!"
#g "\Run BASIC is great!"

'create a blank line
#g "\\There's a blank line above me."

'display on web page
render #g

Print text in desired font face:

'create a graphic object
graphic #g, 600,400

'assign a font to graphic object
#g font("courier new", 24)

'place the drawing pen
#g place(20,200)

'print text in font
#g "\This is Courier New"

'display on web page
render #g

Use two different fonts to display text in a graphic object. This one creates a bold font.

'create a graphic object
graphic #g, 600,400

'assign a font to graphic object
#g font("courier new", 24)

'place the drawing pen
#g place(20,200)

'print text in font
#g "\This is Courier New."

'assign a font to graphic object
#g font("courier new", 14, "bold")
'print text in font
#g "\This is Courier New bold."

'display on web page
render #g

Useful Procedures

' Place a useful function or sub using this keyword here