TX Sheet Control

FontRegistry.measure Method

Method

Read text width/ascent/descent.

Owner: FontRegistry. Package: @txtextcontrol/tx-sheet-control-server. Version: 2.0.0.

Syntax

measure(text: string, css: string): { width: number; actualBoundingBoxAscent: number; actualBoundingBoxDescent: number; }

Parameters

ParameterTypeOptionalDescription
textstringNoLiteral text; leading zeros and equals signs are preserved.
cssstringNoOperation-specific input; see the owning type for units and scope.

Return Value

{ width: number; actualBoundingBoxAscent: number; actualBoundingBoxDescent: number; }.

Examples

Pass an existing FontRegistry from the owning document. Related handles and input bytes must belong to the intended document and application; the function applies the operation and inspects its result.

function applyFontRegistryMeasure(fontRegistry: { measure(argument0: string, argument1: string): unknown }) {
    const result = fontRegistry['measure']('Invoice total', '11px "Liberation Sans"');
    console.log(result);
}

Remarks

Use this member on an object from the current document. Reacquire document-bound handles after replacement/deletion. Validate arguments against the declared types and documented bounds; handle exceptions or rejected promises.

See Also