Original Author Paul Laughton, 2011
Page 173
De Re BASIC!
The parameter <exp> follows the same rules as Gr.text.width (see above) to get a text string and the
text attributes (typeface, size, and style) used to measure the string.
The coordinates of the rectangle are reported as if Gr.text.draw positioned your text at 0,0. You get the
actual boundaries of a text object by adding the textbounds offsets to the actual x,y coordinates of the
Gr.text.draw command.
In typeface terminology, the coordinate values are offsets from the beginning of the baseline of the text
(see Gr.text.draw and Gr.text.height for more explanation of the lines that define where text is drawn).
This is why the value returned for "top" is always a negative number.
If this is confusing, try running this example:
GR.OPEN ,,,,,-1
GR.COLOR 255,255,0,0,0
GR.TEXT.SIZE 40
GR.TEXT.ALIGN 1
s$ = "This is only a test"
GR.GET.TEXTBOUNDS s$,l,t,r,b
PRINT l,t,r,b
x=10 : y=50
GR.RECT rct,l+x,t+y,r+x,b+y
GR.TEXT.DRAW txt,x,y,s$
GR.RENDER
PAUSE 5000
Gr.text.draw <object_number_nvar>, <x_nexp>, <y_nexp>, <text_object_sexp>
Creates and inserts a text object (<text_object_sexp>) into the Display List. The text object will use the
latest color and text preparatory commands. The <object_number_nvar> returns the Display List object
number for this text. This object will not be visible until the Gr.render command is called.
Gr.text.draw positions the text so the the bodies of the characters sit on a line called the baseline. The
tails of letters like "y" hang below the baseline.The y value <y_nexp> sets the location of this baseline.
The Gr.text.height command tells you the locations of the various lines used to draw text. The
Gr.text.width command tells you width of the space in which a specific string will be drawn. The
Gr.get.textbounds command tells you the locations of the left-, top-, right-, and bottom-most pixels
actually drawn for a specific text string.
The Gr.modify parameters for Gr.text.draw are "x", "y", and "text". The value for "text" is a string
representing the new text.