What is the MIME type for TTF files?

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 ?


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.


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.


I know this is quite old, but still nobody seems to have provided a concrete example fix. So here we are for future generations:

I had the same problem with Apache2 and Chrome. Chrome would warn that a file sent with the mime-type of application/octet-stream was really a font file - which it was.

The fix for me was to add the following line in my apache2 config file:

AddType application/x-font-ttf .ttf

ps:

I had tried to update the magic file but that failed to work after full apache2 reloads. The matches I tried (using real tab characters between fields, and per the above referenced magic patterns) are below:

  # True Type fonts
  0 string  0001000000  application/x-font-ttf
  0 string  0001000000  TrueType font data mime  application/x-font-ttf
链接地址: http://www.djcxy.com/p/46982.html

上一篇: 设置字体无效的过期标题

下一篇: 什么是TTF文件的MIME类型?