Web Font MIME Types Config for web.xml

I recently came across a Java web app container with decrepite defaults. The SAP owned Web Application server did not have any MIME types for serving web fonts!! Such disappoint in the web.xml!

You'll note that web fonts (@font-face) have been around for quite a while, see the can i use page.

The CSS from an agency used custom fonts, and they included all the mappings to try and cover all historic variations of fonts that different browsers eat. This is probably good.

However the short answer for web fonts in 2014 is that you probably want to provide TTF for every browser except IE to use, and for IE you probably want to provide EOT for the IE versions to use, or perhaps just WOFF if you only need IE9+ support.

Here is a snippet in the hope it helps you out.


<!--
Set up MIME type mappings so that we can serve modern web fonts.  For reference see:
http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts/10864297#10864297

eot   =>  "application/vnd.ms-fontobject"
woff  =>  "application/font-woff" (per my last paragraph)
ttf   =>  "application/x-font-ttf" or "application/x-font-truetype"
svg   =>  "image/svg+xml"
otf   =>  "application/x-font-opentype"
-->

<mime-mapping>
    <extension>eot</extension>
    <mime-type>application/vnd.ms-fontobject</mime-type>
</mime-mapping>

<mime-mapping>
    <extension>woff</extension>
    <mime-type>application/font-woff</mime-type>
</mime-mapping>

<mime-mapping>
    <extension>ttf</extension>
    <mime-type>application/x-font-ttf</mime-type>
</mime-mapping>

<mime-mapping>
    <extension>svg</extension>
    <mime-type>image/svg+xml</mime-type>
</mime-mapping>

<mime-mapping>
    <extension>otf</extension>
    <mime-type>application/x-font-opentype</mime-type>
</mime-mapping>


Copyright © 2013 by Damon van Opdorp.