Table of Contents

TTMSFNCGraphics.CalculateTextWidth Method

Returns the rendered width of AText in pixels when constrained to ARect.

API unit family: TMSFNCGraphics Declaring type: TTMSFNCGraphics

Overloads

Overload 1

Returns the rendered width of AText in pixels when constrained to ARect.

function CalculateTextWidth(AText: string; ARect: TRectF; AWordWrapping: Boolean = False; ASupportHTML: Boolean = True): Single; overload; virtual;

Parameters

Name Description
AText Text string to measure.
ARect Constraint rectangle that limits the available rendering area.
AWordWrapping When True, wraps text at word boundaries within ARect. Default is False.
ASupportHTML When True, interprets HTML tags in the text. Default is True.

Returns

The rendered width of the text in floating-point pixels.

Overload 2

Returns the single-line rendered width of AText in floating-point pixels using the current font.

function CalculateTextWidth(AText: string): Single; overload; virtual;

Parameters

Name Description
AText Text string to measure.

Returns

The rendered width in floating-point pixels.

Overload 3

Returns the rendered width of AText in whole pixels when constrained to ARect (TRect).

function CalculateTextWidth(AText: string; ARect: TRect; AWordWrapping: Boolean = False; ASupportHTML: Boolean = True): Integer; overload; virtual;

Parameters

Name Description
AText Text string to measure.
ARect Constraint rectangle in integer pixels.
AWordWrapping When True, wraps text at word boundaries within ARect. Default is False.
ASupportHTML When True, interprets HTML tags in the text. Default is True.

Returns

The rendered width of the text in whole pixels.