diff --git a/lib/prawn/text.rb b/lib/prawn/text.rb index 801822caf..976fc7216 100644 --- a/lib/prawn/text.rb +++ b/lib/prawn/text.rb @@ -208,8 +208,10 @@ def formatted_text(array, options = {}) end end - remaining_text = fill_formatted_text_box(remaining_text, options) - draw_remaining_formatted_text_on_new_pages(remaining_text, options) + unless @all_text_printed + remaining_text = fill_formatted_text_box(remaining_text, options) + draw_remaining_formatted_text_on_new_pages(remaining_text, options) + end end else remaining_text = fill_formatted_text_box(array, options) diff --git a/spec/text_spec.rb b/spec/text_spec.rb index 11efd0c14..661555c4a 100644 --- a/spec/text_spec.rb +++ b/spec/text_spec.rb @@ -445,6 +445,17 @@ expect(x_positions[3]).to eq(0) end + describe "when paragraph has only one line, it should not add" \ + " additional leading" do + let(:leading) { 100 } + + it 'should add leading only once' do + _y = @pdf.y + @pdf.text("hello", indent_paragraphs: 10, leading: leading) + expect(_y - @pdf.y).to be < leading*2 + end + end + describe "when wrap to new page, and first line of new page" \ " is not the start of a new paragraph, that line should" \ " not be indented" do