Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indent_paragrahs/no final_gap line spacing bug #1079

Conversation

jstasiak
Copy link
Contributor

In case of no indent_paragraphs when formatted_text is called it
passes the text to render to Text.fill_formatted_text_box. Then the text
is rendered using the Box class and the Box class in combination with
the Wrap module takes care of spacing between lines. Spacing is present
regardless of final_gap value.

In case of indent_paragraphs set the situation is different.
formatted_text itself prints the first line separately and then the rest
of the text. As such, it has the responsibility to add spacing between
the first line and the rest on its own. When final_gap is set, as it is
by default, it works just fine. When final_gap is not set though, there
was no space between the first line and the second line of the text.

Since formatted_text calls draw_indented_formatted_line to render the
first line and draw_indented_formatted_line calls
fill_formatted_text_box with the single_line flag we can use the flag as
a secondary way to trigger adding a gap.

@jstasiak jstasiak force-pushed the fix-line-spacing-with-indentation-and-no-final_gap branch from e89bedb to 42c7d0b Compare September 25, 2018 00:02
@jstasiak
Copy link
Contributor Author

My first approach was buggy in case of single-line paragraphs, I just updated it.

@petergoldstein
Copy link
Contributor

@pointlessone Could you please rebase this one? I think we likely want to merge this once it's green.

@pointlessone pointlessone force-pushed the fix-line-spacing-with-indentation-and-no-final_gap branch from 42c7d0b to 9b586d0 Compare February 15, 2022 11:56
In case of no indent_paragraphs when formatted_text is called it
passes the text to render to Text.fill_formatted_text_box. Then the text
is rendered using the Box class and the Box class in combination with
the Wrap module takes care of spacing between lines. Spacing is present
regardless of final_gap value.

In case of indent_paragraphs set the situation is different.
formatted_text itself prints the first line separately and then the rest
of the text. As such, it has the responsibility to add spacing between
the first line and the rest on its own. When final_gap is set, as it is
by default, it works just fine. When final_gap is not set though, there
was no space between the first line and the second line of the text.

Since formatted_text calls draw_indented_formatted_line to render the
first line and draw_indented_formatted_line calls
fill_formatted_text_box with the single_line flag we can use the flag as
a secondary way to trigger adding a gap.

I also added a test case for a single line scenario because my initial
take on this issue introduced a different bug that caused a single-line
paragraph and another paragraph to have too much space between them.
@pointlessone pointlessone force-pushed the fix-line-spacing-with-indentation-and-no-final_gap branch from 9b586d0 to 3fdbda8 Compare January 4, 2024 15:51
@pointlessone pointlessone merged commit 2a10105 into prawnpdf:master Jan 4, 2024
9 of 14 checks passed
@pointlessone
Copy link
Member

@jstasiak Thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants