Skip to content

Commit a26f9c1

Browse files
tledouxtofi86
authored andcommitted
handle no src uri in fonts, fixes #773, correct embedded font boolean in xml output
1 parent 91deb63 commit a26f9c1

16 files changed

+493
-17
lines changed

src/main/java/com/adobe/epubcheck/css/CSSHandler.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ private void handleFontFaceInfo()
333333
(((fontStyle != null) && !"normal".equalsIgnoreCase(fontStyle)) ? "," + fontStyle : "") +
334334
(((fontWeight != null) && !"normal".equalsIgnoreCase(fontWeight)) ? "," + fontWeight : "")
335335
);
336-
report.info(path, FeatureEnum.REFERENCE, fontUri);
336+
if (fontUri != null) {
337+
report.info(path, FeatureEnum.REFERENCE, fontUri);
338+
}
337339
}
338340
}
339341
}

src/main/java/com/adobe/epubcheck/util/XmlReportAbstract.java

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public void message(Message message, EPUBLocation location, Object... args) {
122122

123123
@Override
124124
public void info(String resource, FeatureEnum feature, String value) {
125+
// Dont store 'null' values
126+
if (value == null) return;
127+
125128
switch (feature) {
126129
case TOOL_DATE:
127130
if (value != null && !value.startsWith("$")) {

src/main/java/com/adobe/epubcheck/util/XmlReportImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public int generateReport()
164164
generateElement("name", "Font");
165165
startElement("values", KeyValue.with("arity", "List"), KeyValue.with("type", "Property"));
166166
generateProperty("FontName", getNameFromPath(f), "String");
167-
generateProperty("FontFile", false);
167+
generateProperty("FontFile", true);
168168
endElement("values");
169169
endElement("property");
170170
}

src/test/java/com/adobe/epubcheck/test/css_Test.java

+6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public void font_face_xmp_Test() throws Exception
5959
runCSSXmpTest("font-face", 1);
6060
}
6161

62+
@Test
63+
public void font_family_no_src_xml_Test() throws Exception
64+
{
65+
runCSSXmlTest("font-family-no-src", 1);
66+
}
67+
6268
// @Test
6369
public void unused_epub3_Test() throws Exception
6470
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
3+
<rootfiles>
4+
<rootfile full-path="OPS/content.opf" media-type="application/oebps-package+xml"/>
5+
</rootfiles>
6+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="BOGUS" version="3.0">
3+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
4+
<dc:title>Font Face Sample Book</dc:title>
5+
<dc:language>en</dc:language>
6+
<dc:identifier id="BOGUS">000000000000000000</dc:identifier>
7+
<meta property="dcterms:modified">2012-10-10T12:00:00Z</meta>
8+
</metadata>
9+
<manifest>
10+
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
11+
<item id="toc" properties="nav" href="toc.xhtml" media-type="application/xhtml+xml"/>
12+
<item id="page01" href="external_css.xhtml" media-type="application/xhtml+xml" />
13+
<item id="page02" href="style_tag_css.xhtml" media-type="application/xhtml+xml" />
14+
<item id="page03" href="inline_css.xhtml" media-type="application/xhtml+xml" />
15+
<item id="style" href="styles/style.css" media-type="text/css"/>
16+
</manifest>
17+
<spine toc="ncx">
18+
<itemref idref="page01" />
19+
<itemref idref="page02" />
20+
<itemref idref="page03" />
21+
</spine>
22+
</package>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE html>
3+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4+
<head>
5+
<title>Font-Face - External CSS</title>
6+
<link rel="stylesheet" type="text/css" href="styles/style.css"/>
7+
</head>
8+
<body>
9+
<div>
10+
<h1>Font-Face specified in external css file</h1>
11+
<table>
12+
<tr>
13+
<td>
14+
<div class="myFont">This is standard font.</div>
15+
</td>
16+
</tr>
17+
<tr>
18+
<td>
19+
<div class="myFont1">This should be a different font.</div>
20+
</td>
21+
</tr>
22+
<tr>
23+
<td>
24+
<div class="myFont2">This should be a different font.</div>
25+
</td>
26+
</tr>
27+
<tr>
28+
<td>
29+
<div class="myFont3">This should be a different font.</div>
30+
</td>
31+
</tr>
32+
<tr>
33+
<td>
34+
<div class="myFont4">This references a missing font.</div>
35+
</td>
36+
</tr>
37+
<tr>
38+
<td>
39+
<div class="myFont5">This references an incorrect font path.</div>
40+
</td>
41+
</tr>
42+
<tr>
43+
<td>
44+
<div class="myFont6">This references a null font path.</div>
45+
</td>
46+
</tr>
47+
<tr>
48+
<td>
49+
<div class="ex1">This references font style.</div>
50+
</td>
51+
</tr>
52+
<tr>
53+
<td>
54+
<div class="myFont7">This references an external font</div>
55+
</td>
56+
</tr>
57+
</table>
58+
</div>
59+
</body>
60+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE html>
3+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4+
<head>
5+
<title>Font-Face - Inline CSS</title>
6+
</head>
7+
<body>
8+
<h1>Font-Face - Inline CSS</h1>
9+
10+
<p>Using the @font-face rule isn't possible inline.</p>
11+
</body>
12+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE html>
3+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4+
<head>
5+
<title>Font-Face - Style Tag CSS</title>
6+
<style>
7+
@font-face {
8+
font-family: "bloody";
9+
src: url('fonts/bloody.woff');
10+
}
11+
12+
@font-face {
13+
font-family: "badaboom";
14+
src: url('fonts/badaboom.woff');
15+
}
16+
17+
div {
18+
font-family: bloody;
19+
}
20+
21+
.noRef{
22+
font-family: "badaboom";
23+
}
24+
25+
.externalFont {
26+
font-family: 'Chela One';
27+
}
28+
</style>
29+
</head>
30+
<body>
31+
32+
<p><b>Note:</b> Internet Explorer 9 only supports .eot fonts.</p>
33+
34+
<div>
35+
This is an embedded font.
36+
</div>
37+
<p class="noRef">Reference to font that is missing from the package.</p>
38+
<p class="externalFont">Reference to an external font.</p>
39+
</body>
40+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
@font-face {
2+
font-family: brankovic;
3+
}
4+
5+
@font-face {
6+
font-family: fummel;
7+
}
8+
9+
@font-face {
10+
font-family: "bloody";
11+
}
12+
13+
@font-face {
14+
font-family: "bloody_wrong";
15+
}
16+
17+
@font-face {
18+
font-family: "badaboom";
19+
}
20+
21+
.ex1 {
22+
font: 5em arial, sans-serif
23+
}
24+
25+
.myFont {
26+
font-size: xx-large;
27+
color: maroon;
28+
}
29+
30+
.myFont1 {
31+
font-family: brankovic;
32+
font-size: xx-large;
33+
color: maroon;
34+
}
35+
36+
.myFont2 {
37+
font-family: fummel;
38+
font-size: xx-large;
39+
color: maroon;
40+
}
41+
42+
.myFont3 {
43+
font-family: bloody;
44+
font-size: xx-large;
45+
color: maroon;
46+
}
47+
48+
.myFont4 {
49+
font-family: badaboom;
50+
font-size: xx-large;
51+
color: maroon;
52+
}
53+
54+
.myFont5 {
55+
font-family: bloody_wrong;
56+
font-size: xx-large;
57+
color: maroon;
58+
}
59+
60+
.myFont6 {
61+
font-family: null;
62+
font-size: 3em;
63+
color: #8a2be2;
64+
}
65+
66+
.myFont7 {
67+
font-family: "Bitstream Vera Serif Bold", serif
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
3+
<head>
4+
<meta name="dtb:uid" content=""/>
5+
<meta name="dtb:depth" content="1"/>
6+
<meta name="dtb:totalPageCount" content="0"/>
7+
<meta name="dtb:maxPageNumber" content="0"/>
8+
</head>
9+
<docTitle>
10+
<text>Transform Style Test</text>
11+
</docTitle>
12+
<navMap>
13+
<navPoint id="np-1" playOrder="1">
14+
<navLabel>
15+
<text>Font-Face - External CSS</text>
16+
</navLabel>
17+
<content src="external_css.xhtml"/>
18+
</navPoint>
19+
</navMap>
20+
</ncx>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE html>
3+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
4+
5+
<head>
6+
<title>Table of Contents</title>
7+
</head>
8+
<body>
9+
<nav epub:type="toc">
10+
<ol>
11+
<li><a href="external_css.xhtml">External CSS</a></li>
12+
<li><a href="style_tag_css.xhtml">Style Tag</a></li>
13+
<li><a href="inline_css.xhtml">Inline Style</a></li>
14+
</ol>
15+
</nav>
16+
</body>
17+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
application/epub+zip

0 commit comments

Comments
 (0)