FontText

Graphic Text and Fonts
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.

Syntax for displaying text in a graphic object: //To draw text at the current position use this form://
 * 1) handle "\this text will show up"

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.

Font method 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

Simple demo that prints some text in a graphic object: code format="vbnet" 'create a graphic object graphic #g, 600,400

'place the drawing pen
 * 1) g place(20,200)

'print text
 * 1) g "\Hello, World!"

'display on web page render #g code

Demo of new lines in graphic text: code format="vbnet" 'create a graphic object graphic #g, 600,400

'place the drawing pen
 * 1) g place(20,40)

'print text
 * 1) g "\Hello, World!"
 * 2) g "\Run BASIC is great!"

'create a blank line
 * 1) g "\\There's a blank line above me."

'display on web page render #g code

Print text in desired font face: code format="vbnet" 'create a graphic object graphic #g, 600,400

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

'place the drawing pen
 * 1) g place(20,200)

'print text in font
 * 1) g "\This is Courier New"

'display on web page render #g code

Use two different fonts to display text in a graphic object. This one creates a bold font. code format="vbnet" 'create a graphic object graphic #g, 600,400

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

'place the drawing pen
 * 1) g place(20,200)

'print text in font
 * 1) g "\This is Courier New."

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

'display on web page render #g code