Contents Previous Next Subchapters

Determining The Size of Text In a Dialog Window
See Also: addcontrol

Syntax
textsize(text)
TextSize(
text)

Description
Description Returns a matrix containing the number of pixels wide and high that is used to display each row of text using the current system font. The routine textsize is an intrinsic function and requires text to be a character row vector. The routine TextSize is defined in the include file guisize.oms and allows text to be an arbitrary character matrix. The Return value is a two column integer matrix in which the first column is the width of the corresponding row of text and the second column is the height of the corresponding row of text.

Example
If you enter
     text = "line 1"
     textsize(text)
O-Matrix will respond with a two element row vector in which the first element is the width and the second element is the height of "line 1" in pixels.

If the file guisize.oms has not yet been included, enter the command
     include guisize.oms
If you enter
     text = {"line 1", "line two"} 
     TextSize(text)
O-Matrix will respond with a 2 by 2 matrix in which the first row contains the size of "line 1" in pixels and the second matrix contains the size of "line two" in pixels.

Reference
The current display adapter resolution and system font affects the value returned by these routines. Trailing blanks with in each row of text are ignored unless the entire line is blank in which case the size of one space is returned. If text has zero row dimension, the return value is the integer row vector [0, 0].