width = TextWidth(string$[, t])
width = TextWidth(string$[, encoding])
string$
if it was rendered on the display. So it takes care of the currently
selected font as well as the font style.
Please note: This function returns the cursor advancement of the text. This is often less than the text actually occupies when rendered to the display. If you need detailed information about the real extent of a text, please use the function TextExtent() instead.
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:
width = TextWidth("Hello World")
pos = (640 - width) / 2
Locate(pos, 0)
Print("Hello World")
The above code centers the text "Hello World" horizontally on a
640 pixel-wide display.