Hard coded font-face ressource in epub.css

Jan Ulrich Hasecke avatarJan Ulrich Hasecke created an issue

In epub.css there is a hardcoded font-face ressource url which throws an error in validation with epubcheck

@font-face {
    font-family: "LiberationNarrow";
    font-style: normal;
    font-weight: normal;
    src: url("res:///Data/fonts/LiberationNarrow-Regular.otf")
        format("opentype");
}
@font-face {
    font-family: "LiberationNarrow";
    font-style: oblique, italic;
    font-weight: normal;
    src: url("res:///Data/fonts/LiberationNarrow-Italic.otf")
        format("opentype");
}
@font-face {
    font-family: "LiberationNarrow";
    font-style: normal;
    font-weight: bold;
    src: url("res:///Data/fonts/LiberationNarrow-Bold.otf")
        format("opentype");
}
@font-face {
    font-family: "LiberationNarrow";
    font-style: oblique, italic;
    font-weight: bold;
    src: url("res:///Data/fonts/LiberationNarrow-BoldItalic.otf")
        format("opentype");
}

As ebook readers have default fonts which override this I think that this could be deleted entirely. At least the Liberation fonts declarations are not needed. They are referenced a few times in epub.css.

Comments (8)

  1. Roland Meister

    I am probably the only one that actually uses the settings. So if there is a general consent to remove the direcitves, that's fine with me (although that means work for me to reactivate the directives). Also the settings only apply to a rather old type of reader, the newer ones probably have other ways to select custom fonts. But I do not want to lose the information about using @font-face, so if the directives are removed, an example should be added to the FAQ.

    However, I'm not sure if the only reason is to get rid of a few warnings from epubcheck or if there are other issues, e.g. with kindlegen. In that case I know of at least one more problem with the css as it is now (hidden elements). A custom kindle theme with it's own css file that fixes the css issues and removes the @font-face directives seems to be the more general solution. The css file can then also implement all recommendations from amazon's kindle style guide.

  2. Georg Brandl

    Well, I guess that epubcheck passing (as much as possible) is not a bad goal. And since you admit you are probably the main audience for the font-face directives I vote for removing them.

  3. Jan Ulrich Hasecke

    As Amazons Kindle Format and ePub are de facto standards today I would vote for a solution that passes epubcheck and can be converted by kindlegen without problems. My problem lately was that the Kindle Direct Publishing Platform rejected a ePub file made by sphinx. Generally KDP accepts ePubs. I had to convert the ePub to Kindle via Calibre to upload the file. Kindlegen would be the other option to convert ePubs to mobi.

    I would guess that the font face directive only works when all fonts are included in the ePub. I am not sure whether Sphinx already copies fonts to the e-book directory.

  4. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.