nextspace
    Preparing search index...

    Function estimateTextWidth

    • Roughly how wide a string renders, without measuring it in the DOM.

      Close enough to lay labels out: the ratio is the average advance width of the typeface as a fraction of its size, and a label whose estimate is a few pixels out still reads, whereas measuring every label on every frame of a running simulation would not.

      Parameters

      • text: string
      • fontSize: number
      • ratio: number = 0.55

      Returns number