Skip to content

Commit

Permalink
Fix measuring text when OpenType features are passed in to .text() (f…
Browse files Browse the repository at this point in the history
…oliojs#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 committed Dec 31, 2024
1 parent df20359 commit 9838c57
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## pdfkit changelog

### Unreleased

- Fix measuring text when OpenType features are passed in to .text()

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

- Fix index not counting when rendering ordered lists (#1517)
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 9838c57

Please sign in to comment.