measureText method

  1. @override
PTextMetric measureText(
  1. String text,
  2. PFont font
)
override

Measure the text dimension.

Implementation

@override
PTextMetric measureText(String text, PFont font) {
  var bitmapFont = font.toBitmapFont();

  var w = 0;

  var lng = text.length;
  for (var i = 0; i < lng; ++i) {
    var c = text[i];
    var x = _characterXAdvance(bitmapFont, c);
    w += x;
  }

  var h = _findStringHeight(bitmapFont, text);

  return PTextMetric(w, h);
}