createPaths method

  1. @override
List<ShapePath> createPaths(
  1. String text,
  2. double size,
  3. Map<String, dynamic> data
)
override

Implementation

@override
List<ShapePath> createPaths(
    String text, double size, Map<String, dynamic> data) {
  // final chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // workaround for IE11, see #13988
  List<String> chars = text.split("");

  double scale = size / data["resolution"];
  double lineHeight = (data["boundingBox"]["yMax"] -
          data["boundingBox"]["yMin"] +
          data["underlineThickness"]) *
      scale;

  List<ShapePath> paths = [];

  double offsetX = 0.0;
  double offsetY = 0.0;

  for (int i = 0; i < chars.length; i++) {
    final char = chars[i];

    if (char == '\n') {
      offsetX = 0;
      offsetY -= lineHeight;
    }
    else {
      final ret = createPath(char, scale, offsetX, offsetY, data);
      offsetX += ret["offsetX"];
      paths.add(ret["path"]);
    }
  }

  return paths;
}