@maxgraph/core
    Preparing search index...

    Function getSizeForString

    • 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 <br> before calling this method. The caller is responsible for sanitizing the HTML markup.

      Example:

      const label = graph.getLabel(cell).replace(/\n/g, "<br>");
      const 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 DEFAULT_FONTSIZE.

      • fontFamily: string = DEFAULT_FONTFAMILY

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

      • textWidth: null | number = null

        Optional width for text wrapping.

      • fontStyle: null | number = null

        Optional font style.

      Returns Rectangle