fix(text_region): apply Paragraph.ln(h) height to the line it terminates - #1904
#1904Open
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#1904Sanjays2402 wants to merge 1 commit intopy-pdf:masterpy-pdf/fpdf2:masterfrom Sanjays2402:fix/textregion-ln-custom-heightSanjays2402/fpdf2:fix/textregion-ln-custom-heightCopy head branch name to clipboard
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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1786
Paragraph.ln(h)passes a custom height by appending a"\n"fragment with its font size inflated toh. InMultiLineBreak.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 becausecurrent_font_heightwas 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/AA mention of the change is present in
CHANGELOG.mdThis 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.