Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(text_region): apply Paragraph.ln(h) height to the line it terminates - #1904

#1904
Open
Sanjays2402 wants to merge 1 commit into
py-pdf:masterpy-pdf/fpdf2:masterfrom
Sanjays2402:fix/textregion-ln-custom-heightSanjays2402/fpdf2:fix/textregion-ln-custom-heightCopy head branch name to clipboard
Open

fix(text_region): apply Paragraph.ln(h) height to the line it terminates#1904
Sanjays2402 wants to merge 1 commit into
py-pdf:masterpy-pdf/fpdf2:masterfrom
Sanjays2402:fix/textregion-ln-custom-heightSanjays2402/fpdf2:fix/textregion-ln-custom-heightCopy head branch name to clipboard

Conversation

@Sanjays2402

Copy link
Copy Markdown

Fixes #1786

Paragraph.ln(h) passes a custom height by appending a "\n" fragment with its font size inflated to h. In MultiLineBreak.get_line() that height was only used when the line had no other fragments, so normally it was dropped from the line the break terminates; it then leaked onto the next line because current_font_height was raised from the already-consumed fragment before it was skipped. The result was the extra gap landing between the first and second line of the following paragraph instead of before it.

Checklist:

  • A unit test is covering the code added / modified by this PR

  • In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder — N/A

  • A mention of the change is present in CHANGELOG.md

  • This PR is ready to be merged

By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.

Paragraph.ln(h) appends a newline fragment whose font size is inflated to
the requested height. MultiLineBreak.get_line() only used that height when
the line had no other fragments, so for the common case the gap was
dropped from the terminated line and instead leaked onto the next line
via current_font_height, which was updated before the already-consumed
fragment was skipped.

The extra spacing therefore appeared between the first and second line of
the following paragraph instead of before it.

The newline fragment's height is now folded into the line it terminates,
and exhausted fragments are skipped before they can raise the running
font height for the next line.

Closes py-pdf#1786
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextRegion.ln() not working properly when h is provided

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.