jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Use `font/otf` MIME type

Open basil opened this issue 1 year ago • 3 comments
trafficstars

A .otf file on a web server is more likely to be an OpenType Font than an OpenDocument Formula Template.

Reference:

https://www.iana.org/assignments/media-types/font/otf

Also matches Apache httpd

basil avatar Jul 27 '24 00:07 basil

Any update on this PR? Changes were requested in https://github.com/jetty/jetty.project/pull/12097#pullrequestreview-2203161786, but that review failed to take into account the point made in the first sentence of this pull request—that between two equally valid MIME type choices, preference should be given to font/otf because a .otf file on a web server is more likely to be an OpenType Font (e.g. using the @font-face CSS rule) than an OpenDocument Formula Template (a preference also shared by Apache httpd).

basil avatar Aug 07 '24 20:08 basil

OpenType Font Format: https://learn.microsoft.com/en-us/typography/opentype/spec/otff

File Extension: otf

Most browsers today (desktop, phone, ebooks, television, embedded systems, etc) support these mime types for OpenType Format fonts.

  • application/vnd.ms-opentype - valid to IANA (part of vendor sub-type)
  • application/x-font-opentype - valid to IANA (not registered)
  • application/x-font-otf - valid to IANA (not registered)
  • application/font-sfnt - valid registration at IANA

If you used anything else (eg: application/octet-stream), you would often get warnings and such from browsers that the mime-type is not right, but it will use OpenType Font Format instead of what the server said in it's Content-Type response header (ignoring what the server said).

Then, in March 2013, IETF gets around to establishing the font/ top level mimetype.

  • https://datatracker.ietf.org/doc/html/rfc8081
  • https://datatracker.ietf.org/doc/html/rfc8081#section-4.4.3

Which defined the following mime-type.

  • font/otf - registered at IANA (uncommon in usage, few browsers support this, mostly commonly used by ebooks)

But it's barely used, and has poor support across the industry. The browsers instead have started to support this mime-type with the font/ top level.

  • font/opentype - not registered at IANA. (in super common usage, preferred by chrome and safari webkit)

This PR proposes that font/otf be used, which is actually probably the worst choice of the above mime-types.

For maximum compatibility, users would be better served by using font/opentype, or application/x-font-opentype which has far better support across the industry as of today.

Because this is mime-type is so unclear, the best choice is actually to let the web application to decide what they want it to be, and that web application can decide if it wants to reject certain browsers or not based on their decision.

I'm not in favor of changing this to font/otf (yet). But I'll let other committers here speak up if they want.

joakime avatar Aug 14 '24 23:08 joakime

font/opentype - not registered at IANA. (in super common usage, preferred by chrome and safari webkit) […] For maximum compatibility, users would be better served by using font/opentype, or application/x-font-opentype which has far better support across the industry as of today.

@joakime Where are you getting this information? I would be happy to use the OpenType font MIME type that is the most correct/supported, but I do not (yet) see any evidence behind your claims. Here is the evidence I used to pick the font/otf MIME type:

For Chromium:

  • https://github.com/search?q=repo%3Achromium%2Fchromium+%22font%2Fotf%22&type=code 3 references to font/otf in production code
  • https://github.com/search?q=repo%3Achromium%2Fchromium+%22font%2Fopentype%22&type=code No references to font/opentype
  • https://github.com/search?q=repo%3Achromium%2Fchromium+%22application%2Fx-font-opentype%22&type=code No references to application/x-font-opentype

For WebKit:

  • https://github.com/search?q=repo%3AWebKit%2FWebKit+%22font%2Fotf%22&type=code 4 references to font/otf, 3 in test code and 1 in production code Source/WebInspectorUI/UserInterface/Base/MIMETypeUtilities.js
  • https://github.com/search?q=repo%3AWebKit%2FWebKit+%22font%2Fopentype%22&type=code 2 references to font/opentype, only in test code
  • https://github.com/search?q=repo%3AWebKit%2FWebKit+%22application%2Fx-font-opentype%22&type=code No references to application/x-font-opentype

For Gecko:

  • https://github.com/search?q=repo%3Amozilla%2Fgecko-dev+%22font%2Fotf%22&type=code 3 references to font/otf, 2 in test code and 1 in production code netwerk/base/nsNetUtil.cpp
  • https://github.com/search?q=repo%3Amozilla%2Fgecko-dev+%22font%2Fopentype%22&type=code 17 references to font/opentype, only in test code
  • https://github.com/search?q=repo%3Amozilla%2Fgecko-dev+%22application%2Fx-font-opentype%22&type=code No references to application/x-font-opentype
  • font/otf documented in Mozilla's list of MIME types at https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

basil avatar Aug 15 '24 00:08 basil

@basil I think this pr needs a merge from the current head of 12.0.x.

janbartel avatar Oct 22 '24 22:10 janbartel

@janbartel I have executed git merge origin/jetty-12.0.x

basil avatar Oct 22 '24 22:10 basil

as it's non compatible change, this will go to 12.1.x @basil can you please change the target to jetty-12.1.x. jetty-12.1.0.alpha0 might be soon

olamy avatar Oct 30 '24 21:10 olamy

@basil can you please change the target to jetty-12.1.x

@olamy Sure, I have retargeted this PR to jetty-12.1.x.

basil avatar Oct 30 '24 22:10 basil