Fix rendering of TextPath one more time

This commit is contained in:
Anton Lavrenov 2020-11-23 10:09:11 -05:00
parent f50019f176
commit 14156b3222
5 changed files with 18 additions and 22 deletions

View File

@ -3,8 +3,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 7.2.0
* New property `fillAfterStrokeEnabled` for `Konva.Shape`. See API docs for more information.
* Fix for `Konva.Transformer` when it may fail to draw.
* Fix rendering of `TextPath` one more time.
## 7.1.9

View File

@ -8,7 +8,7 @@
* Konva JavaScript Framework v7.1.9
* http://konvajs.org/
* Licensed under the MIT
* Date: Sun Nov 22 2020
* Date: Mon Nov 23 2020
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@ -14461,7 +14461,7 @@
var attempts = 0;
p1 = undefined;
while (Math.abs(glyphWidth - currLen) / glyphWidth > 0.01 &&
attempts < 5) {
attempts < 20) {
attempts++;
var cumulativePathLength = currLen;
while (pathCmd === undefined) {
@ -14520,15 +14520,10 @@
}
}
else if (glyphWidth > currLen) {
currentT += (glyphWidth - currLen) / pathCmd.pathLength;
currentT += (glyphWidth - currLen) / pathCmd.pathLength / 2;
}
else {
currentT = currentT - (currLen - glyphWidth) / pathCmd.pathLength;
// that one is a weird check
// but I have to add it to fix some drawings (they are in the testing)
if (currentT < 0) {
currentT += 0.02;
}
currentT = Math.max(currentT - (currLen - glyphWidth) / pathCmd.pathLength / 2, 0);
}
if (currentT > 1.0) {
currentT = 1.0;

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -297,7 +297,7 @@ export class TextPath extends Shape<TextPathConfig> {
p1 = undefined;
while (
Math.abs(glyphWidth - currLen) / glyphWidth > 0.01 &&
attempts < 5
attempts < 20
) {
attempts++;
var cumulativePathLength = currLen;
@ -384,14 +384,12 @@ export class TextPath extends Shape<TextPathConfig> {
currentT = glyphWidth / pathCmd.pathLength;
}
} else if (glyphWidth > currLen) {
currentT += (glyphWidth - currLen) / pathCmd.pathLength;
currentT += (glyphWidth - currLen) / pathCmd.pathLength / 2;
} else {
currentT = currentT - (currLen - glyphWidth) / pathCmd.pathLength;
// that one is a weird check
// but I have to add it to fix some drawings (they are in the testing)
if (currentT < 0) {
currentT += 0.02;
}
currentT = Math.max(
currentT - (currLen - glyphWidth) / pathCmd.pathLength / 2,
0
);
}
if (currentT > 1.0) {

View File

@ -740,7 +740,7 @@ suite('TextPath', function () {
var rect = textpath.getClientRect();
assert.equal(rect.height, 332.3365704376247, 'check height');
assert.equal(rect.height, 328.9307620828596, 'check height');
textpath.text('');
rect = textpath.getClientRect();
@ -789,7 +789,7 @@ suite('TextPath', function () {
layer.draw();
var rect = textpath.getClientRect();
assert.equal(rect.width, 298.50744485064837);
assert.equal(rect.height, 170.74755779649587);
assert.equal(rect.width, 298.50662860798093);
assert.equal(rect.height, 170.7386880372827);
});
});