DevToolsmith

OTF MIME Type

font/otf is the MIME type for OpenType fonts with PostScript (CFF) outlines. Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
font/otf
Extensions
.otf
Content-Type header
font/otf
Registered
Yes, with IANA
Compress with gzip
Yes, it is text or uncompressed
Category
Fonts

About OpenType font files

OpenType files with CFF outlines start with OTTO; OpenType fonts with TrueType outlines usually use the .ttf extension instead. As with TTF, convert to WOFF2 for the web.

Other types seen for these files: application/x-font-otf , application/font-sfnt . Accept them when reading uploads, but send font/otf yourself.

File signature

OTF files start with 4F 54 54 4F ("OTTO"). The extension and the type a browser reports for an upload both come from the file name, so check these bytes on the server before trusting a file.

Serve .otf with the right Content-Type

Response header
Content-Type: font/otf
nginx (a line in the types { } block of mime.types)
font/otf otf;
Apache (.htaccess or server config)
AddType font/otf .otf
Caddy
@otf path *.otf
header @otf Content-Type "font/otf"
Check what a server sends
curl -sI https://example.com/file.otf | grep -i '^content-type'
# Content-Type: font/otf

Set the type in code

Node.js (Express)
res.set('Content-Type', 'font/otf');
// Or make the browser download it:
res.attachment('file.otf');
Python
import mimetypes

mimetypes.add_type('font/otf', '.otf')  # if your system doesn't know it
mimetypes.guess_type('file.otf')[0]  # 'font/otf'
Go
mime.AddExtensionType(".otf", "font/otf")
w.Header().Set("Content-Type", "font/otf")

Accept .otf uploads

HTML
<input type="file" accept=".otf,font/otf">

The accept attribute only filters the file picker; users can still choose another file. Listing the extension as well as the type matters, because operating systems don’t always report the type you expect.

Related types

  • .ttf (font/ttf): TrueType font
  • .woff2 (font/woff2): WOFF2 font
  • .woff (font/woff): WOFF font

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What is the MIME type for .otf files?

font/otf. You may also see application/x-font-otf, application/font-sfnt, which are older or unofficial; send font/otf. The full header is "Content-Type: font/otf".

Why does my server send the wrong Content-Type for .otf?

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .otf is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".

How can I check that a file really is OTF?

Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. OTF files start with 4F 54 54 4F ("OTTO"). The MIME type lookup on this site reads them for you when you drop a file on it.