Fix incorrect handling of line-height CSS in HTML → PDF conversion#1427
Fix incorrect handling of line-height CSS in HTML → PDF conversion#1427RadekWikturna wants to merge 1 commit intoLibrePDF:1.3-java8from
Conversation
|
|
I wonder if anyone can have a look, so that the pull request could be accepted. I've described the issue in detail, including the cause. All tests pass. Note: Some SonarCloud Code Analysis and Codacy Code Analysis report some problem - but NOT in the new code but elsewhere. |
|
I'm rather disappointed that there's no activity towards merging this fix. My previous 3 pull requests were merged pretty fast and this one is just waiting. Can I do anything to make it happen? @asturio, can you help? |




Description of the new Feature/Bugfix
When parsing HTML with a span styled with line-height (e.g., <span "line-height:115%">), the generated Paragraph in OpenPDF 1.3.x computed the multiplied leading incorrectly, resulting in overlapping lines (see attached PDF file).
Expected behavior:
For font size 12pt and line-height:115%, the total leading should be ≈ 13.8pt (12 × 1.15).
Cause:
FactoryProperties.insertStyle, line 383 handles line-height in percentage (by dividing by 100) although the percentage handling is done already inMarkup.parseLength(String string, float actualFontSize), line 553.The problem was most likely introduced by: #1059 When converting HTML to PDF, font size specified in % is interpreted as pixels
Solution:
Adjusted
FactoryProperties.insertStyle- removed handling line-height in percentage.Added a JUnit test (
testLineHeightPercentage) that parses a small HTML snippet with line-height:115% and asserts thatParagraph.getTotalLeading()matches the expected value.Unit-Tests for the Bugfix
Compatibilities Issues
None
Your real name
Radek Wikturna
Testing details
Any other details about how to test the new feature or bugfix?
Line Height Percentage.pdf