createPaths method

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

Implementation

List<ShapePath> createPaths(String text, double size, Map<String, dynamic> data) {
  // var 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 (var i = 0; i < chars.length; i++) {
    var char = chars[i];

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

  return paths;
}