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
Content-Type: font/otf
font/otf otf;
AddType font/otf .otf
@otf path *.otf
header @otf Content-Type "font/otf"
curl -sI https://example.com/file.otf | grep -i '^content-type'
# Content-Type: font/otf
Set the type in code
res.set('Content-Type', 'font/otf');
// Or make the browser download it:
res.attachment('file.otf');
import mimetypes
mimetypes.add_type('font/otf', '.otf') # if your system doesn't know it
mimetypes.guess_type('file.otf')[0] # 'font/otf'
mime.AddExtensionType(".otf", "font/otf")
w.Header().Set("Content-Type", "font/otf")
Accept .otf uploads
<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
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.