world.WindowTextWidth
Calculates the width of text in a miniwindow
Prototype
long WindowTextWidth(BSTR WindowName, BSTR FontId, BSTR Text, BOOL Unicode);
Description
This calculates how many pixels a particular piece of text will take up, which can help in calculating how big a window to create, or where to put other things. Note that WindowText returns the number of pixels when it draws text, so you don't need to call WindowTextWidth simply to work out where to draw the very next item.
WindowName - the name of an existing miniwindow.
FontId - a font id that you have loaded.
Text - the text to be calculated (maximum of 8192 characters)
Unicode - if true, the text is Unicode text in UTF-8 format
For more information, see:
http://www.gammon.com.au/mushclient/mw_text.htm
Lua example
width = WindowTextWidth (win, "f", "Lazy dog yawns") -- width of text
Return value
If successful, returns the number of pixels the text would take horizontally.
If unsuccessful, returns a negative number as follows:
-1 : That window name does not exist
-2 : That font was not loaded
-3 : For Unicode, invalid UTF-8 sequence
Related topic
See also
| Function | Description |
|---|---|
| WindowCreate | Creates a miniwindow |
| WindowFont | Loads a font into a miniwindow |
| WindowFontInfo | Returns information about a font |
| WindowFontList | Lists all fonts loaded into a miniwindow |
| WindowText | Draws text into a miniwindow |