Skip to content

Commit

Permalink
Fix measuring text when OpenType features are passed in to .text() (#…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
bbloomf and liborm85 authored Dec 25, 2024
1 parent 7527b7a commit eecfb4c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions tests/visual/text.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
});
});

});

0 comments on commit eecfb4c

Please sign in to comment.