createPaths2 method
Implementation
Map<String, dynamic> createPaths2(
String text, num size, Map<String, dynamic> data) {
List<String> chars = text.split("");
num scale = size / data["resolution"];
num lineHeight = (data["boundingBox"]["yMax"] -
data["boundingBox"]["yMin"] +
data["underlineThickness"]) *
scale;
// List<ShapePath> paths = [];
Map<String, Map<String, dynamic>> paths = {};
List<Map<String, dynamic>> result = [];
num offsetX = 0.0;
num offsetY = 0.0;
num maxWidth = 0.0;
for (var i = 0; i < chars.length; i++) {
var char = chars[i];
if (char == '\n') {
offsetX = 0;
offsetY -= lineHeight;
} else {
var charPath = paths[char];
if (charPath == null) {
var ret = createPath(char, scale, 0.0, 0.0, data);
paths[char] = ret;
charPath = ret;
}
Map<String, dynamic> charData = {
"char": char,
"offsetX": offsetX,
"offsetY": offsetY
};
result.add(charData);
offsetX += charPath["offsetX"];
// paths.add(ret["path"]);
if (offsetX > maxWidth) {
maxWidth = offsetX;
}
}
}
Map<String, dynamic> _data = {
"paths": paths,
"chars": result,
"height": offsetY + lineHeight,
"width": maxWidth
};
return _data;
}