DevToolsmith

TTF MIME Type

font/ttf is the MIME type for TrueType fonts. Here is the Content-Type header to send, the file signature, and how to configure servers and code.

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

About TrueType font files

Desktop font files. Browsers can load them with @font-face, but they are uncompressed and much larger than the same font as WOFF2. Convert them (for example with fonttools’ pyftsubset, which can also strip unused characters) before using them on a site, and check the font’s license allows web embedding.

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

File signature

TTF files start with 00 01 00 00. 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 .ttf with the right Content-Type

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

Set the type in code

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

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

Accept .ttf uploads

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

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

  • .otf (font/otf): OpenType 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 .ttf files?

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

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

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .ttf 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 TTF?

Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. TTF files start with 00 01 00 00. The MIME type lookup on this site reads them for you when you drop a file on it.