findStringHeight function

int findStringHeight(
  1. BitmapFont font,
  2. String string
)

Implementation

int findStringHeight(BitmapFont font, String string) {
  var stringHeight = 0;
  final chars = string.codeUnits;
  for (var c in chars) {
    if (!font.characters.containsKey(c)) {
      continue;
    }
    final ch = font.characters[c]!;
    if (ch.height + ch.yoffset > stringHeight) {
      stringHeight = ch.height + ch.yoffset;
    }
  }
  return (stringHeight * 1.05).round();
}