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 ?
You can open a TTF file in Microsoft Windows Font Viewer (Windows), Apple Font Book (Mac), or iFont (iOS, Android).
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With