Skip to content

Commit 896fa46

Browse files
committed
Add a new font selector test. Fix cmps.
DEVSIX-1685
1 parent 60922bf commit 896fa46

File tree

7 files changed

+82
-7
lines changed

7 files changed

+82
-7
lines changed

src/test/java/com/itextpdf/html2pdf/css/FontFaceTest.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,16 @@ This file is part of the iText (R) project.
5656
import com.itextpdf.test.annotations.LogMessage;
5757
import com.itextpdf.test.annotations.LogMessages;
5858
import com.itextpdf.test.annotations.type.IntegrationTest;
59-
60-
import java.io.ByteArrayOutputStream;
61-
import java.io.File;
62-
import java.io.IOException;
63-
6459
import org.junit.Assert;
6560
import org.junit.BeforeClass;
6661
import org.junit.Ignore;
6762
import org.junit.Test;
6863
import org.junit.experimental.categories.Category;
6964

65+
import java.io.ByteArrayOutputStream;
66+
import java.io.File;
67+
import java.io.IOException;
68+
7069
@Category(IntegrationTest.class)
7170
public class FontFaceTest extends ExtendedITextTest {
7271
public static final String sourceFolder = "./src/test/resources/com/itextpdf/html2pdf/css/FontFaceTest/";
@@ -107,6 +106,11 @@ public void droidSerifLocalWithMediaRuleFontTest2() throws IOException, Interrup
107106
runTest("droidSerifLocalWithMediaRuleFontTest2");
108107
}
109108

109+
@Test
110+
public void fontSelectorTest01() throws IOException, InterruptedException {
111+
runTest("fontSelectorTest01");
112+
}
113+
110114
@Test
111115
@LogMessages(messages = {@LogMessage(messageTemplate = LogMessageConstant.UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI)})
112116
public void fontFaceGrammarTest() throws IOException, InterruptedException {
@@ -217,13 +221,14 @@ public void w3cProblemTest07() throws IOException, InterruptedException {
217221
}
218222

219223
@Test
220-
//TODO: DEVSIX-1519
221224
public void incorrectFontNameTest01() throws IOException, InterruptedException {
222225
runTest("incorrectFontNameTest01");
223226
}
224227

225228
@Test
226-
//TODO: DEVSIX-1519
229+
// The result of te test is FAIL. However we consider it to be correct.
230+
// Although the font-family specified by the paragraph's class doesn't match the one of fontface,
231+
// font's full name contains specified font-family and iText takes it into account.
227232
public void incorrectFontNameTest02() throws IOException, InterruptedException {
228233
runTest("incorrectFontNameTest02");
229234
}
@@ -234,6 +239,11 @@ public void incorrectFontNameTest03() throws IOException, InterruptedException {
234239
runTest("incorrectFontNameTest03");
235240
}
236241

242+
@Test
243+
public void incorrectFontNameTest04() throws IOException, InterruptedException {
244+
runTest("incorrectFontNameTest04");
245+
}
246+
237247
private void runTest(String name) throws IOException, InterruptedException {
238248
String htmlPath = sourceFolder + name + ".html";
239249
String pdfPath = destinationFolder + name + ".pdf";
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2+
<html>
3+
<head>
4+
<title>Display the title in pdf</title>
5+
<style type="text/css">
6+
*{ font-family: "arial", "tahoma", "helvetica", "sans-serif"; }
7+
p { font-family : "arial", "tahoma", "helvetica", "sans-serif";}
8+
h1 { font-family : "arial", "tahoma", "helvetica", "sans-serif";}
9+
10+
div{
11+
font-family : "arial", "tahoma", "helvetica", "sans-serif";
12+
padding:20px;
13+
}
14+
</style>
15+
</head>
16+
<body>
17+
<h1>ArialMT should be used instead of Arial Narrow</h1>
18+
<div>
19+
<table>
20+
<tr>
21+
<td>
22+
The case can be described as follows: narrow font doesn't get into equals block of conditions, but contains one.
23+
</td>
24+
</table>
25+
</div>
26+
27+
<div>
28+
<br/><br/><br/>
29+
30+
<p>But that shouldn't be highly awarded, should it?</p>
31+
</div>
32+
33+
</body>
34+
</html>

src/test/resources/com/itextpdf/html2pdf/css/FontFaceTest/incorrectFontNameTest02.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
<body>
1919
<p>This test passes if next line says F</p>
2020
<p class="test">F</p>
21+
<p>The previous line says FAIL. However we consider it to be correct.
22+
Although the font-family specified by the paragraph's class doesn't match the one of fontface,
23+
font's full name contains specified font-family and iText takes it into account.</p>
2124
</body>
2225
</html>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<style type="text/css">
6+
@font-face {
7+
font-family: "abyrvalg";
8+
src: url("w3c-test-fonts/valid-005.ttf") format("TrueType");
9+
}
10+
@font-face {
11+
font-family: "WOFF Test TTF";
12+
src: url("web-fonts/droid-serif-bold.ttf") format("TrueType");
13+
}
14+
15+
body {
16+
font-size: 20px;
17+
}
18+
.test {
19+
font-family: "WOFF Test TTF";
20+
}
21+
22+
</style>
23+
</head>
24+
<body>
25+
<p class="test">PF</p>
26+
27+
</body>
28+
</html>

0 commit comments

Comments
 (0)