Skip to content

Commit 683c28f

Browse files
authored
Merge pull request #410 from syjer/366-fix-bold-list-no-reason
ListItemPainter: set font specification when calling drawText fixes #366
2 parents fc14fc9 + 0dfcc8f commit 683c28f

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ private static void drawText(RenderingContext c, BlockBox box, IdentValue listSt
134134

135135
c.getOutputDevice().setColor(box.getStyle().getColor());
136136
c.getOutputDevice().setFont(box.getStyle().getFSFont(c));
137+
if (c.getOutputDevice() instanceof AbstractOutputDevice) {
138+
((AbstractOutputDevice) c.getOutputDevice()).setFontSpecification(box.getStyle().getFontSpecification());
139+
}
137140
c.getTextRenderer().drawString(
138141
c.getOutputDevice(), text.getText(), x, y);
139142
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<head>
3+
<style>
4+
p {
5+
page-break-after: always;
6+
}
7+
</style>
8+
</head>
9+
<body>
10+
<p>
11+
<b>bolded text</b>
12+
</p>
13+
<ol>
14+
<li>counter should not be bold</li>
15+
</ol>
16+
</body>
17+
</html>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,15 @@ public void testFloatClearBoth() throws IOException {
890890
public void testBorderRadius() throws IOException {
891891
assertTrue(vt.runTest("border-radius"));
892892
}
893+
894+
/**
895+
* Check counter style after page break, it should not be affected by a previous bolded text, see issue
896+
* https://github.com/danfickle/openhtmltopdf/issues/366
897+
*/
898+
@Test
899+
public void testListCounterAfterPageBreak() throws IOException {
900+
assertTrue(vt.runTest("list-counter-after-page-break"));
901+
}
893902

894903
// TODO:
895904
// + Elements that appear just on generated overflow pages.

0 commit comments

Comments
 (0)