Contents

measureText

Determines the width of the bounding box required to render the specified text with the current font settings.

Declaration

TextMetrics measureText(
    DOMString text
);

Parameters

  • text:

    A string containing the text to measure.

Return Value

An object whose width property contains the width in pixels of the bounding box needed to render the text without clipping.

Discussion

Use this method to determine how much space is needed to render a string, or to measure the width of an existing string.

See Also

Drawing Text