Skip to content

Commit

Permalink
fix: line width computation (#1858)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomura authored Jun 4, 2022
1 parent d958b0a commit 70c3c9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-birds-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@react-pdf/layout': patch
---

fix: line width computation
4 changes: 2 additions & 2 deletions packages/layout/src/text/linesWidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import advanceWidth from '@react-pdf/textkit/lib/attributedString/advanceWidth';
* @returns {Number} lines width
*/
const linesWidth = node => {
if (!node.lines) return -1;
return Math.max(...node.lines.map(line => advanceWidth(line)));
if (!node.lines) return 0;
return Math.max(0, ...node.lines.map(line => advanceWidth(line)));
};

export default linesWidth;

0 comments on commit 70c3c9f

Please sign in to comment.