Fix incorrect rendering of TextPath in some cases

This commit is contained in:
Anton Lavrenov 2020-11-16 11:12:23 -05:00
parent e609654880
commit ae8dd87e2f
5 changed files with 37 additions and 5 deletions

View File

@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## 7.1.6
* Fix incorrect rendering of `TextPath` in some cases.
## 7.1.6
* Fix for correct image/dataURL/canvas exports for `Konva.Stage`.
## 7.1.5

View File

@ -8,7 +8,7 @@
* Konva JavaScript Framework v7.1.6
* http://konvajs.org/
* Licensed under the MIT
* Date: Tue Nov 10 2020
* Date: Mon Nov 16 2020
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@ -14391,7 +14391,7 @@
var attempts = 0;
p1 = undefined;
while (Math.abs(glyphWidth - currLen) / glyphWidth > 0.01 &&
attempts < 25) {
attempts < 50) {
attempts++;
var cumulativePathLength = currLen;
while (pathCmd === undefined) {

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 < 25
attempts < 50
) {
attempts++;
var cumulativePathLength = currLen;

View File

@ -709,4 +709,32 @@ suite('TextPath', function () {
rect = textpath.getClientRect();
assert.equal(rect.height, 0, 'check height');
});
test('check bad calculations', function () {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
var textpath = new Konva.TextPath({
x: 100,
y: 150,
fill: '#333',
fontSize: 16,
text:
'__________________________________________________________________________________________________________________________________________________________________________________________________________________',
data:
'M 109.98618090452261 138.6656132223618 C 135.94577638190955 48.80547503140701 149.91187876884422 79.79800957914573 151.40954773869348 117.23973382537689 S 123.00811620603017 419.616741991206 122.84170854271358 460.0538041771357 S 134.33883542713568 469.8304329459799 149.98115577889448 464.33898005653265 S 245.4620163316583 411.5856081972362 257.1105527638191 412.91686950376885 S 239.31850251256282 474.434854428392 249.96859296482413 475.76611573492465 S 338.21036306532665 425.67526648869347 348.5276381909548 424.3440051821608 S 337.3640408291457 461.1772344535176 338.5288944723618 464.33898005653265 S 346.8778454773869 466.79295744346734 358.52638190954775 451.4834524183417',
});
layer.add(textpath);
layer.draw();
var rect = textpath.getClientRect();
assert.equal(rect.height, 412.4370496991363, 'check height');
textpath.text('');
rect = textpath.getClientRect();
assert.equal(rect.height, 0, 'check height');
});
});