measuretext(
TEXT
,
FONTNAME
,
FONTSIZE
)

The measuretext( function returns the size of a string of text in a particular font and size.


Parameters

This function has three parameters:

text – text to be measured.

fontname – name of the font.

fontsize – size of the font, in points (there are 72 points in an inch).


Description

This function measures the width and height of a string of text. The result is returned as a Point which includes both the vertical and horizontal measurement (see Graphic Coordinates). Usually you’ll just be interested in the width or the height, so you can use the h( or v( functions to extract the dimension you are interested. In all cases, the measurement is returned in points (1 inch = 72 points). (Don’t confuse a Point, which combines vertical and horizontal coordinates into a single value, with points, a measurement unit.)

h(measuretext("Hello World","Gill Sans",15)) ☞ 75
v(measuretext("Hello World","Gill Sans",15)) ☞ 21
h(measuretext("Hello World","Noteworthy",15)) ☞ 65
v(measuretext("Hello World","Noteworthy",15)) ☞ 30

The vertical measurement does not take word wrapping into account, it assumes that the text can grow infinitely to the right. So the height is reflective of the height of the font, and the number of carriage returns or linefeeds in the text.

Note: If the specified font does not exist on your computer, the returned height and width will both be zero.

Note: In addition to the actual fonts installed on your system, you can also specify any standard system font: #SystemFont, #SystemBoldFont, #ControlFont, #FixedPitchFont, #LabelFont, #MenuBarFont, #MenuFont, #MessageFont, #PaletteFont, #TitleBarFont or #ToolTipsFont.


See Also


History

VersionStatusNotes
10.2NewNew in this version.