From 00bfdc1e5a6c673d2de7b3ab09d5020e932562fb Mon Sep 17 00:00:00 2001 From: Osman Cea Date: Mon, 25 Nov 2024 21:38:31 -0300 Subject: [PATCH] fix(textkit): make indentation only affect first line. (#2975) --- .changeset/selfish-rivers-serve.md | 5 +++++ packages/textkit/src/layout/layoutParagraph.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/selfish-rivers-serve.md diff --git a/.changeset/selfish-rivers-serve.md b/.changeset/selfish-rivers-serve.md new file mode 100644 index 000000000..12dcc8bf6 --- /dev/null +++ b/.changeset/selfish-rivers-serve.md @@ -0,0 +1,5 @@ +--- +"@react-pdf/textkit": patch +--- + +fix issue with indentation shrinking all lines diff --git a/packages/textkit/src/layout/layoutParagraph.js b/packages/textkit/src/layout/layoutParagraph.js index fec2ffcc0..aec782bd1 100644 --- a/packages/textkit/src/layout/layoutParagraph.js +++ b/packages/textkit/src/layout/layoutParagraph.js @@ -82,7 +82,7 @@ const layoutParagraph = (engines, options) => { const rects = generateLineRects(container, height); const availableWidths = rects.map((r) => r.width); - availableWidths[0] -= indent; + availableWidths.unshift(availableWidths[0] - indent); const lines = engines.linebreaker(options)(paragraph, availableWidths);