StringWidth
Str255 string ; address of Pascal string to measure returns width of the string if displayed
StringWidth returns the width, in pixels, a string of text would occupy if it were drawn in the current font and size. If the current style is plain or
underline, StringWidth returns the width for writing the string in the current style. If the current style is italic or bold, StringWidth returns the width for writing the string in plain style.
string is the address of a Pascal-style length-prefixed string; the text to
measure.
Returns: the width of the string, in pixels.
Notes: Usually, you can consider StringWidth functions as a series of calls to CharWidth, returning the sum of the widths obtained by that call. But if you use scaled or fractional-width fonts while measuring a string,
StringWidth may compute a length different from what repeated calls to CharWidth will compute. It may also be different than what you'd get by draws a string of the same length that StringWidth computes. The differences are due to rounding errors, since QuickDraw uses fixed- point
math. For example, if the current size is 11 but the System file doesn't
contain an 11-point version of the current font, the System will scale the
12-point version down, and will probably en counter rounding errors.
Use TextWidth to measure strings longer than 255 bytes or other unformatted text. Use MeasureText to obtain an array, with each element containing the width of the text from the start to the right edge of the
corresponding character. See SpaceExtra for a way to fully-justify a line of text.