extent = TextExtent(string$[, t])
extent = TextExtent(string$[, encoding])
TextExtent()
calculates the exact bounding box for the specified string.
This function returns a table with information in the following fields:
MinX:
MinY:
MaxX:
MaxY:
Width:
Height:
The values in MinX
, MinY
, MaxX
, and MaxY
are always relative to the
current cursor position. For instance, if MinX
is -10, this means that
Print() would start rendering this string -10 pixels from the current
cursor position on the x-axis. The value in Width
specifies where the
cursor would end up after the rendering operation. This is often less
than MaxX-1
. For instance in the case of italic text, the last
character will usually be much behind the final cursor position.
To calculate the full width of the specified string, simply subtract
MinX
from MaxX
and add 1, i.e. full_width=MaxX-MinX+1
.
Starting with Hollywood 10.0, this function accepts an optional table argument that allows you to specify the following additional options:
Encoding:
string$
.
This defaults to the character encoding set as the text library default
encoding using SetDefaultEncoding().
See SetDefaultEncoding for details. (V10.0)
Charspacing: