Skip to content

Commit

Permalink
fix: properly set font fields in the JSON report
Browse files Browse the repository at this point in the history
All fonts were added to the `refFonts` field, even when embedded. This commit fixes that.

See #1515
Fix #1519
  • Loading branch information
rdeltour committed Jul 6, 2023
1 parent 7804c78 commit 8575a6b
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/adobe/epubcheck/css/CSSHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ else if (propertyName.equals("src"))
URL fontURL = parsedURLs.get(((CssURI) construct).toUriString());
if (fontURL != null && context.resourceRegistry.isPresent())
{
fontURI = context.relativize(fontURL);
// check font mimetypes
String fontMimeType = context.getMimeType(fontURL);
if (fontMimeType != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
<title>Minimal EPUB</title>
</head>
<body>
<h1>Loomings</h1>
<p>Call me Ishmael.</p>
</body>
</html>
Empty file.
14 changes: 14 additions & 0 deletions src/test/resources/reporting/files/fonts-embedded/EPUB/nav.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
18 changes: 18 additions & 0 deletions src/test/resources/reporting/files/fonts-embedded/EPUB/package.opf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="q">NOID</dc:identifier>
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
</metadata>
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
<item id="css" href="style.css" media-type="text/css" properties="remote-resources"/>
<item id="font" href="font.woff" media-type="font/woff"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@font-face {
font-family: "Open Sans";
src: url("font.woff") format("woff");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
1 change: 1 addition & 0 deletions src/test/resources/reporting/files/fonts-embedded/mimetype
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
<title>Minimal EPUB</title>
</head>
<body>
<h1>Loomings</h1>
<p>Call me Ishmael.</p>
</body>
</html>
14 changes: 14 additions & 0 deletions src/test/resources/reporting/files/fonts-remote/EPUB/nav.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
18 changes: 18 additions & 0 deletions src/test/resources/reporting/files/fonts-remote/EPUB/package.opf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="q">NOID</dc:identifier>
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
</metadata>
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
<item id="css" href="style.css" media-type="text/css" properties="remote-resources"/>
<item id="font" href="https://example.org/font" media-type="font/woff"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@font-face {
font-family: "Open Sans";
src: url("https://example.org/font") format("woff");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
1 change: 1 addition & 0 deletions src/test/resources/reporting/files/fonts-remote/mimetype
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
16 changes: 16 additions & 0 deletions src/test/resources/reporting/json-report.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
And JSON at '$.items' contains 5 items
And JSON at '$..checkSum' has no null values

## Fonts

Scenario: Font remote
When checking EPUB 'fonts-remote'
Then the JSON report is valid
And JSON at '$.publication.refFonts' is:
| Open Sans |
And JSON at '$.publication.embeddedFonts' is empty

Scenario: Font embedded
When checking EPUB 'fonts-embedded'
Then the JSON report is valid
And JSON at '$.publication.embeddedFonts' is:
| Open Sans |
And JSON at '$.publication.refFonts' is empty

## References

Scenario: cross-HTML references
Expand Down

0 comments on commit 8575a6b

Please sign in to comment.