Skip to content

Commit 19887e0

Browse files
authored
Merge pull request #421 from syjer/420-text-align-justify-npe
handle NPE in justify text edge case #420
2 parents 884194c + ec95f5e commit 19887e0

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/InlineText.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ public float calcTotalAdjustment(JustificationInfo info) {
312312
// letter spacing is already explicitly set.
313313
return 0f;
314314
}
315+
316+
if (_counts == null) {
317+
return 0f;
318+
}
315319

316320
return (_counts.getSpaceCount() * info.getSpaceAdjust()) +
317321
(_counts.getNonSpaceCount() * info.getNonSpaceAdjust());
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<html><body><p style="text-align: justify"><span>a<br />b</span></p></body></html>

openhtmltopdf-examples/src/test/java/com/openhtmltopdf/visualregressiontests/VisualRegressionTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,12 @@ public void testIssue399TableHeaderFooterWithNoRows() throws IOException {
923923
assertTrue(vt.runTest("issue-399-table-header-with-no-rows"));
924924
}
925925

926-
926+
927+
@Test
928+
public void testIssue420JustifyTextNullPointerException() throws IOException {
929+
assertTrue(vt.runTest("issue-420-justify-text-null-pointer-exception"));
930+
}
931+
927932
// TODO:
928933
// + Elements that appear just on generated overflow pages.
929934
// + content property (page counters, etc)

0 commit comments

Comments
 (0)