diff --git a/src/core/text/TextMetrics.js b/src/core/text/TextMetrics.js index 27bd145..c4f32e1 100644 --- a/src/core/text/TextMetrics.js +++ b/src/core/text/TextMetrics.js @@ -69,7 +69,7 @@ const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) - + ((lines.length - 1) * lineHeight); + + ((lines.length - 1) * (lineHeight + style.leading)); if (style.dropShadow) { @@ -83,7 +83,7 @@ height, lines, lineWidths, - lineHeight, + lineHeight + style.leading, maxLineWidth, fontProperties ); diff --git a/src/core/text/TextMetrics.js b/src/core/text/TextMetrics.js index 27bd145..c4f32e1 100644 --- a/src/core/text/TextMetrics.js +++ b/src/core/text/TextMetrics.js @@ -69,7 +69,7 @@ const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) - + ((lines.length - 1) * lineHeight); + + ((lines.length - 1) * (lineHeight + style.leading)); if (style.dropShadow) { @@ -83,7 +83,7 @@ height, lines, lineWidths, - lineHeight, + lineHeight + style.leading, maxLineWidth, fontProperties ); diff --git a/src/core/text/TextStyle.js b/src/core/text/TextStyle.js index 71f31e2..fcc58fc 100644 --- a/src/core/text/TextStyle.js +++ b/src/core/text/TextStyle.js @@ -32,6 +32,7 @@ trim: false, wordWrap: false, wordWrapWidth: 100, + leading: 0, }; /** @@ -86,6 +87,7 @@ * @param {string} [style.textBaseline='alphabetic'] - The baseline of the text that is rendered. * @param {boolean} [style.wordWrap=false] - Indicates if word wrap should be used * @param {number} [style.wordWrapWidth=100] - The width at which text will wrap, it needs wordWrap to be set to true + * @param {number} [style.leading=0] - The space between lines */ constructor(style) { @@ -355,6 +357,19 @@ this.styleID++; } } + + get leading() + { + return this._leading; + } + set leading(leading) + { + if (this._leading !== leading) + { + this._leading = leading; + this.styleID++; + } + } get lineJoin() {