update CHANGELOG with new version

This commit is contained in:
Anton Lavrenov 2016-09-15 17:16:29 -04:00
parent e6c1bd4e78
commit baf3769774
3 changed files with 58 additions and 3 deletions

View File

@ -4,6 +4,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Not released][Not released]
## [1.2.0][2016-09-15]
## Added
- new properties for `Konva.TextPath`: `letterSpacing` and `textBaseline`.
## [1.1.4][2016-09-13]
### Fixed

View File

@ -66,14 +66,14 @@
});
// update text data for certain attr changes
this.on('textChange.konva textStroke.konva textStrokeWidth.konva', that._setTextData);
this.on('textChange.konva textStroke.konva textStrokeWidth.konva letterSpacing.konva', that._setTextData);
that._setTextData();
this.sceneFunc(this._sceneFunc);
this.hitFunc(this._hitFunc);
},
_sceneFunc: function(context) {
context.setAttr('font', this._getContextFont());
context.setAttr('textBaseline', 'middle');
context.setAttr(this.getTextBaseline(), 'middle');
context.setAttr('textAlign', 'left');
context.save();
@ -164,6 +164,8 @@
var that = this;
var size = this._getTextSize(this.attrs.text);
var letterSpacing = this.getLetterSpacing();
this.textWidth = size.width;
this.textHeight = size.height;
@ -198,7 +200,7 @@
};
var findSegmentToFitCharacter = function(c) {
var glyphWidth = that._getTextSize(c).width;
var glyphWidth = that._getTextSize(c).width + letterSpacing;
var currLen = 0;
var attempts = 0;
@ -422,6 +424,27 @@
* @param {String} fontStyle
*/
Konva.Factory.addGetterSetter(Konva.TextPath, 'letterSpacing', 0);
/**
* set letter spacing property. Default value is 0.
* @name letterSpacing
* @method
* @memberof Konva.TextPath.prototype
* @param {Number} letterSpacing
*/
Konva.Factory.addGetterSetter(Konva.TextPath, 'textBaseline', 'middle');
/**
* set textBaseline property. Default value is 'middle'.
* Can be 'top', 'bottom', 'middle', 'alphabetic', 'hanging'
* @name textBaseline
* @method
* @memberof Konva.TextPath.prototype
* @param {Number} textBaseline
*/
/**
* get font style
* @name getFontStyle
@ -431,6 +454,8 @@
Konva.Factory.addGetterSetter(Konva.TextPath, 'fontVariant', NORMAL);
/**
* set font variant. Can be 'normal' or 'small-caps'. 'normal' is the default.
* @name setFontVariant

View File

@ -215,4 +215,29 @@ suite('TextPath', function() {
cloneAndCompareLayer(layer,50);
showHit(layer);
});
test('Text path with letter spacing', function() {
var stage = addStage();
var layer = new Konva.Layer();
var c = "M10,10 C0,0 10,150 100,100 S300,150 400,50";
var textpath = new Konva.TextPath({
stroke: 'black',
strokeWidth: 1,
fill: 'orange',
fontSize: 10,
fontFamily: 'Arial',
letterSpacing: 5,
text: 'All the world\'s a stage, and all the men and women merely players.',
data: c
});
textpath.cache();
layer.add(textpath);
stage.add(layer);
cloneAndCompareLayer(layer,50);
showHit(layer);
});
});