From 037b6194d1451215bbec624365874aaf6da6019d Mon Sep 17 00:00:00 2001 From: picnixz <10796600+picnixz@users.noreply.github.com> Date: Thu, 20 Jul 2023 19:07:43 +0200 Subject: [PATCH] Use RFC 8081 font file MIME types in the EPUB builder (#11486) The "font" top-level media type was formalised via :rfc:`8081` in 2017. Standard MIME types for OTF and TTF fonts have been `registered with IANA`_ as ``font/otf`` and ``font/ttf``. These are also listed in the EPUB 3 `core media types`_ specification. Sphinx-generated EPUB documents including custom OTF or TTF fonts specify a MIME type for those fonts in ``content.opf`` of ``application/x-font-otf`` or ``application/x-font-ttf`` respectively. The ``epubcheck`` application presents informational warnings that these MIME types are non-standard when checking such a generated EPUB document. Adding the correct MIME type will prevent those messages and will also result in a valid EPUB. .. _core media types: https://www.w3.org/TR/epub/#sec-core-media-types .. _registered with IANA: https://www.iana.org/assignments/media-types/media-types.xhtml#font --- sphinx/builders/_epub_base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sphinx/builders/_epub_base.py b/sphinx/builders/_epub_base.py index dfe4877ec..1609c4995 100644 --- a/sphinx/builders/_epub_base.py +++ b/sphinx/builders/_epub_base.py @@ -65,9 +65,9 @@ MEDIA_TYPES = { '.svg': 'image/svg+xml', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', - '.otf': 'application/x-font-otf', - '.ttf': 'application/x-font-ttf', - '.woff': 'application/font-woff', + '.otf': 'font/otf', + '.ttf': 'font/ttf', + '.woff': 'font/woff', } VECTOR_GRAPHICS_EXTENSIONS = ('.svg',)