mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
fix baseline
This commit is contained in:
parent
42f268b976
commit
bf339fa6f7
20
konva.js
20
konva.js
@ -15071,7 +15071,7 @@
|
||||
},
|
||||
_sceneFunc: function(context) {
|
||||
context.setAttr('font', this._getContextFont());
|
||||
context.setAttr(this.getTextBaseline(), 'middle');
|
||||
context.setAttr('textBaseline', this.getTextBaseline());
|
||||
context.setAttr('textAlign', 'left');
|
||||
context.save();
|
||||
|
||||
@ -15089,15 +15089,15 @@
|
||||
context.restore();
|
||||
|
||||
//// To assist with debugging visually, uncomment following
|
||||
// context.beginPath();
|
||||
// if (i % 2)
|
||||
// context.strokeStyle = 'cyan';
|
||||
// else
|
||||
// context.strokeStyle = 'green';
|
||||
// var p1 = glyphInfo[i].p1;
|
||||
// context.moveTo(p0.x, p0.y);
|
||||
// context.lineTo(p1.x, p1.y);
|
||||
// context.stroke();
|
||||
context.beginPath();
|
||||
if (i % 2)
|
||||
context.strokeStyle = 'cyan';
|
||||
else
|
||||
context.strokeStyle = 'green';
|
||||
var p1 = glyphInfo[i].p1;
|
||||
context.moveTo(p0.x, p0.y);
|
||||
context.lineTo(p1.x, p1.y);
|
||||
context.stroke();
|
||||
}
|
||||
context.restore();
|
||||
},
|
||||
|
8
konva.min.js
vendored
8
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@ -73,7 +73,7 @@
|
||||
},
|
||||
_sceneFunc: function(context) {
|
||||
context.setAttr('font', this._getContextFont());
|
||||
context.setAttr(this.getTextBaseline(), 'middle');
|
||||
context.setAttr('textBaseline', this.getTextBaseline());
|
||||
context.setAttr('textAlign', 'left');
|
||||
context.save();
|
||||
|
||||
@ -91,15 +91,15 @@
|
||||
context.restore();
|
||||
|
||||
//// To assist with debugging visually, uncomment following
|
||||
// context.beginPath();
|
||||
// if (i % 2)
|
||||
// context.strokeStyle = 'cyan';
|
||||
// else
|
||||
// context.strokeStyle = 'green';
|
||||
// var p1 = glyphInfo[i].p1;
|
||||
// context.moveTo(p0.x, p0.y);
|
||||
// context.lineTo(p1.x, p1.y);
|
||||
// context.stroke();
|
||||
context.beginPath();
|
||||
if (i % 2)
|
||||
context.strokeStyle = 'cyan';
|
||||
else
|
||||
context.strokeStyle = 'green';
|
||||
var p1 = glyphInfo[i].p1;
|
||||
context.moveTo(p0.x, p0.y);
|
||||
context.lineTo(p1.x, p1.y);
|
||||
context.stroke();
|
||||
}
|
||||
context.restore();
|
||||
},
|
||||
|
@ -264,4 +264,35 @@ suite('TextPath', function() {
|
||||
layer.add(textpath);
|
||||
stage.add(layer);
|
||||
});
|
||||
|
||||
|
||||
test('Text with baseline', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
|
||||
var c = "M 10,10 300,10";
|
||||
|
||||
var path = new Konva.Path({
|
||||
stroke: 'red',
|
||||
strokeWidth: 1,
|
||||
data: c
|
||||
});
|
||||
|
||||
layer.add(path);
|
||||
|
||||
var textpath = new Konva.TextPath({
|
||||
fill: 'orange',
|
||||
fontSize: '24',
|
||||
fontFamily: 'Arial',
|
||||
text: 'The quick brown fox jumped over the lazy dog\'s back',
|
||||
data: c,
|
||||
textBaseline: 'top'
|
||||
});
|
||||
textpath.on('mouseover', function() { this.setFill('blue'); layer.drawScene(); });
|
||||
textpath.on('mouseout', function() { this.setFill('orange'); layer.drawScene(); });
|
||||
|
||||
layer.add(textpath);
|
||||
stage.add(layer);
|
||||
showHit(layer);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user