Returns an Rectangle with the size (width and height in pixels) of the given string. The string may contain HTML markup. Newlines should be converted to
before calling this method. The caller is responsible for sanitizing the HTML markup.

Example:

let label = graph.getLabel(cell).replace(/\n/g, "<br>");
let size = graph.getSizeForString(label);
  • Parameters

    • text: string

      String whose size should be returned.

    • fontSize: number = DEFAULT_FONTSIZE

      Integer that specifies the font size in pixels. Default is Constants#DEFAULT_FONTSIZE.

    • fontFamily: string = DEFAULT_FONTFAMILY

      String that specifies the name of the font family. Default is Constants#DEFAULT_FONTFAMILY.

    • textWidth: null | number = null

      Optional width for text wrapping.

    • fontStyle: null | number = null

      Optional font style.

    Returns Rectangle