mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
Merge pull request #541 from VladimirTechMan/master
When rendering multi-line texts, check text decoration flags once
This commit is contained in:
commit
3f3e548e4f
@ -137,9 +137,11 @@ export class Text extends Shape {
|
|||||||
align = this.align(),
|
align = this.align(),
|
||||||
totalWidth = this.getWidth(),
|
totalWidth = this.getWidth(),
|
||||||
letterSpacing = this.letterSpacing(),
|
letterSpacing = this.letterSpacing(),
|
||||||
textDecoration = this.textDecoration(),
|
|
||||||
fill = this.fill(),
|
fill = this.fill(),
|
||||||
fontSize = this.fontSize(),
|
fontSize = this.fontSize(),
|
||||||
|
textDecoration = this.textDecoration(),
|
||||||
|
shouldUnderline = textDecoration.indexOf('underline') !== -1,
|
||||||
|
shouldLineThrough = textDecoration.indexOf('line-through') !== -1,
|
||||||
n;
|
n;
|
||||||
|
|
||||||
context.setAttr('font', this._getContextFont());
|
context.setAttr('font', this._getContextFont());
|
||||||
@ -181,7 +183,7 @@ export class Text extends Shape {
|
|||||||
context.translate((totalWidth - width - padding * 2) / 2, 0);
|
context.translate((totalWidth - width - padding * 2) / 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textDecoration.indexOf('underline') !== -1) {
|
if (shouldUnderline) {
|
||||||
context.save();
|
context.save();
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
|
|
||||||
@ -200,7 +202,7 @@ export class Text extends Shape {
|
|||||||
context.stroke();
|
context.stroke();
|
||||||
context.restore();
|
context.restore();
|
||||||
}
|
}
|
||||||
if (textDecoration.indexOf('line-through') !== -1) {
|
if (shouldLineThrough) {
|
||||||
context.save();
|
context.save();
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.moveTo(0, 0);
|
context.moveTo(0, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user