mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 04:42:02 +08:00
additional fix
This commit is contained in:
parent
3af5f0f012
commit
f6bcbb7c8f
@ -605,9 +605,11 @@ export class Text extends Shape<TextConfig> {
|
||||
}
|
||||
|
||||
_useBufferCanvas() {
|
||||
const hasUnderline = this.textDecoration().indexOf('underline') !== -1;
|
||||
const hasLine =
|
||||
this.textDecoration().indexOf('underline') !== -1 ||
|
||||
this.textDecoration().indexOf('line-through') !== -1;
|
||||
const hasShadow = this.hasShadow();
|
||||
if (hasUnderline && hasShadow) {
|
||||
if (hasLine && hasShadow) {
|
||||
return true;
|
||||
}
|
||||
return super._useBufferCanvas();
|
||||
|
@ -1022,6 +1022,40 @@ describe('Text', function () {
|
||||
compareCanvases(groupCanvas, text.toCanvas(), 200);
|
||||
});
|
||||
|
||||
it('text with line-through and shadow', function () {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
|
||||
var text = new Konva.Text({
|
||||
text: 'Test',
|
||||
fill: 'black',
|
||||
fontSize: 40,
|
||||
textDecoration: 'line-through',
|
||||
shadowEnabled: true,
|
||||
shadowColor: 'red',
|
||||
shadowOffsetX: 5,
|
||||
shadowOffsetY: 5,
|
||||
});
|
||||
|
||||
layer.add(text);
|
||||
stage.add(layer);
|
||||
|
||||
var trace =
|
||||
'clearRect();save();shadowColor;shadowBlur;shadowOffsetX;shadowOffsetY;drawImage();restore();';
|
||||
|
||||
assert.equal(layer.getContext().getTrace(true), trace);
|
||||
|
||||
// now check result visually
|
||||
// text with red shadow is the same as red text with back text on top
|
||||
const group = new Konva.Group({});
|
||||
layer.add(group);
|
||||
group.add(text.clone({ shadowEnabled: false, x: 5, y: 5, fill: 'red' }));
|
||||
group.add(text.clone({ shadowEnabled: false }));
|
||||
const groupCanvas = group.toCanvas();
|
||||
|
||||
compareCanvases(groupCanvas, text.toCanvas(), 200, 50);
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
it('change font size should update text data', function () {
|
||||
var stage = addStage();
|
||||
|
Loading…
Reference in New Issue
Block a user