Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the MIME type for TTF files?

Tags:

mime

upload

fonts

I can't find correct MIME type for TrueType fonts. I need it because I'm using File Uploading Class (CodeIgniter) to upload files, and I want to allow only TTF to be uploaded. Tried this:

'ttf'   =>  'font/ttf' 'ttf'   =>  'font/truetype' 

With no success.

Any ideas ?

like image 933
CappY Avatar asked Feb 26 '11 16:02

CappY


People also ask

What can open TTF files?

You can open a TTF file in Microsoft Windows Font Viewer (Windows), Apple Font Book (Mac), or iFont (iOS, Android).

What is in a TTF file?

A TrueType font is a font standard and is the major type of font found in both Mac and Microsoft Windows operating systems. It consists of a single binary file which contains a number of tables related to printer and screen versions of the typeface.


2 Answers

TTF font files has the following MIME type: font/ttf.

Before February 2017:

TTF does not have a MIME type assigned. You'll have to use the more general application/octet-stream, which is used to indicate binary data with no assigned MIME type.

like image 149
Ori Avatar answered Sep 28 '22 01:09

Ori


I've seen font/ttf and application/x-font-ttf used as MIME types for TTF. But if your files are being uploaded as application/octet-stream and you don't want to simply trust the .ttf file extension (or if you want to handle files without an extension), you'll have to check the file content to see whether they're TTF files. The UNIX magic file says that a TTF will begin with the 5 bytes

00 01 00 00 00 

(That's 00 01 00 00 from the GDEF table version and the leading 00 from the GlyphClassDef table offset.)

If your file begins with those 5 bytes, it's probably a TTF.

like image 40
dkarp Avatar answered Sep 28 '22 01:09

dkarp