diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ccaf543..efdbd98d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Update fontkit to 2.0 - Update linebreak to 1.1 +- Fix measuring text when OpenType features are passed in to .text() ### [v0.15.2] - 2024-12-15 diff --git a/lib/mixins/text.js b/lib/mixins/text.js index ad4273d0..1ea320f1 100644 --- a/lib/mixins/text.js +++ b/lib/mixins/text.js @@ -282,7 +282,7 @@ export default { const lineGap = options.lineGap || this._lineGap || 0; if (!wrapper) { - return (this.x += this.widthOfString(text)); + return (this.x += this.widthOfString(text, options)); } else { return (this.y += this.currentLineHeight(true) + lineGap); } diff --git a/tests/visual/__image_snapshots__/text-spec-js-text-continued-text-with-open-type-features-1-snap.png b/tests/visual/__image_snapshots__/text-spec-js-text-continued-text-with-open-type-features-1-snap.png new file mode 100644 index 00000000..8eaebda3 Binary files /dev/null and b/tests/visual/__image_snapshots__/text-spec-js-text-continued-text-with-open-type-features-1-snap.png differ diff --git a/tests/visual/text.spec.js b/tests/visual/text.spec.js index b44d2cd2..5e13c649 100644 --- a/tests/visual/text.spec.js +++ b/tests/visual/text.spec.js @@ -92,4 +92,13 @@ describe('text', function() { doc.fillColor('#000').list(['One', ['One.One', 'One.Two'], 'Three'], 100, 150, {listType: 'numbered'}); }) }) + + test('continued text with OpenType features', function() { + return runDocTest(function(doc) { + doc.font('tests/fonts/Roboto-Regular.ttf'); + doc.text('Really simple', 100, 100, {features: ['smcp'], continued: true, lineBreak: false}) + doc.text(' text', {features: [], lineBreak: false}); + }); + }); + });