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
This commit is contained in:
picnixz 2023-07-20 19:07:43 +02:00 committed by GitHub
parent 571becb6af
commit 037b6194d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,9 +65,9 @@ MEDIA_TYPES = {
'.svg': 'image/svg+xml', '.svg': 'image/svg+xml',
'.jpg': 'image/jpeg', '.jpg': 'image/jpeg',
'.jpeg': 'image/jpeg', '.jpeg': 'image/jpeg',
'.otf': 'application/x-font-otf', '.otf': 'font/otf',
'.ttf': 'application/x-font-ttf', '.ttf': 'font/ttf',
'.woff': 'application/font-woff', '.woff': 'font/woff',
} }
VECTOR_GRAPHICS_EXTENSIONS = ('.svg',) VECTOR_GRAPHICS_EXTENSIONS = ('.svg',)