fix: prevent TextRegion.ln(h) from causing double line break#1803
Closed
Pawansingh3889 wants to merge 1 commit intopy-pdf:masterfrom
Closed
fix: prevent TextRegion.ln(h) from causing double line break#1803Pawansingh3889 wants to merge 1 commit intopy-pdf:masterfrom
Pawansingh3889 wants to merge 1 commit intopy-pdf:masterfrom
Conversation
When ln() is called with a custom h value inside a text region, the inflated font_size_pt on the newline fragment bleeds into the next line's height calculation, producing an unwanted double line break. This fix appends a reset fragment with the original font size after the height-inflated newline fragment, preventing the size from carrying over to subsequent content.
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.
Problem
When calling with a custom height inside a region, the next paragraph gets an unwanted extra line break. This happens because sets on the newline fragment, and this inflated font size bleeds into the height calculation of the next line.
Fix
After appending the height-inflated newline fragment, append a second newline fragment with the original (uninflated) font size. This resets the line height context so subsequent content renders at the correct size.
Testing
Tested with the reproduction script from #1786:
Before: Line 2 had an extra blank line above it.
After: Line 2 renders immediately after the 16pt gap, matching the behavior of outside text regions.