Skip to content

Commit eecfb4c

Browse files
bbloomfliborm85
andauthored
Fix measuring text when OpenType features are passed in to .text() (#1492)
* Update text.js to fix measuring text when opentype features are passed in to .text() * added simple test * Update CHANGELOG.md --------- Co-authored-by: Libor M. <[email protected]>
1 parent 7527b7a commit eecfb4c

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Update fontkit to 2.0
66
- Update linebreak to 1.1
7+
- Fix measuring text when OpenType features are passed in to .text()
78

89
### [v0.15.2] - 2024-12-15
910

lib/mixins/text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export default {
282282
const lineGap = options.lineGap || this._lineGap || 0;
283283

284284
if (!wrapper) {
285-
return (this.x += this.widthOfString(text));
285+
return (this.x += this.widthOfString(text, options));
286286
} else {
287287
return (this.y += this.currentLineHeight(true) + lineGap);
288288
}
15.7 KB
Loading

tests/visual/text.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,13 @@ describe('text', function() {
9292
doc.fillColor('#000').list(['One', ['One.One', 'One.Two'], 'Three'], 100, 150, {listType: 'numbered'});
9393
})
9494
})
95+
96+
test('continued text with OpenType features', function() {
97+
return runDocTest(function(doc) {
98+
doc.font('tests/fonts/Roboto-Regular.ttf');
99+
doc.text('Really simple', 100, 100, {features: ['smcp'], continued: true, lineBreak: false})
100+
doc.text(' text', {features: [], lineBreak: false});
101+
});
102+
});
103+
95104
});

0 commit comments

Comments
 (0)