Calculating the size of a piece of text in a given fontΒΆ

TextSize()

Calculating the size of a piece of text in a given font


SYNTAX

TextSize(window_id, text, font, width, height)

Calculates the width and height, in the units expressed by sys.Unit, of the given text with the given font.

window_id

The identifier of the window in which the text would be placed, or NULL if it is to be printed.

text

The text whose size is to be calculated. Can be a field, expression or quoted string.

font

The font parameter requires the same syntax as a window or control font clause (see Fonts for details). Unless a valid font specification is provided, the default specified in Section 1.4 (Default font) of the terminal parameter file is used. The standard terminal parameter file for all versions of Windows is $SCULPTOR/term/mswin.s. If no default font is defined, then Courier New@10 (Courier New, 10 point) is used as the default.

The font parameter can be supplied as a field, expression or quoted string.

width
height

The function returns in these fields the actual width and height of the rectangle containing the text. The values returned are in the unit defined by sys.Unit. This defaults to device units, but may be set to centimetres or inches.

Note

Any program using this function must include the file <draw.h>.


RELATED TOPICS

Drawing operations

Draw functions

ImageSize()