fix path calculations

This commit is contained in:
Anton Lavrenov
2019-10-11 09:14:53 -05:00
parent d6c6d87b73
commit 7de82e5823
4 changed files with 91 additions and 1336 deletions

View File

@@ -441,11 +441,13 @@ export class TextPath extends Shape<TextPathConfig> {
}
};
// fake search for offset, this is very bad approach
// find other way to add offset from start (for align)
// fake search for offset, this is the best approach
var testChar = 'C';
var glyphWidth = that._getTextSize(testChar).width + letterSpacing;
for (var k = 0; k < offset / glyphWidth; k++) {
var lettersInOffset = offset / glyphWidth - 1;
// the idea is simple
// try to draw testChar until we fill offset
for (var k = 0; k < lettersInOffset; k++) {
findSegmentToFitCharacter(testChar);
if (p0 === undefined || p1 === undefined) {
break;