How can I convert TTF files to OTF format?
Solution 1
you can use TTF file format directly in css :
@font-face {
font-family: Vinegar;
src: url(http://www.4bit.co.uk/testing/design01/vinegar.ttf);
}
h3 {
font-family: Vinegar, "Times New Roman", Times, serif;
}
It is working!
Or you can use this link to generate your font face!
Solution 2
If you are on Linux, you can use FontForge, which can be scripted from Python.
#!/usr/bin/python
import fontforge
font = fontforge.open("STIXGeneral.otf")
font.generate("STIXGeneral.ttf")
Here is a longer python script that does this for a whole directory at a time:
http://fonts.fileformat.info/bin/otf2ttf.py
Solution 3
It was painfully hard to find how to do it correctly. Here is how I got it to work on OS X
$ brew install fontforge
$ fontforge -c 'Open("my.ttf"); Generate("my.otf")'
I was desperately looking for pip install fontforge
which does not exist and I haven't got it to work with python - I guess you need to compile it with --enable-pyextension
or something.
Solution 4
A quick Google search for ttf otf converter
gave me a number of results, such as:
https://onlinefontconverter.com
http://www.freefontconverter.com
No idea how well they work, but you can try them.
Solution 5
For cross browser/mobile support you definitely need at least three formats:
-
Embedded OpenType:
eot
for Internet Explorer 6-8.
There is a command line converter: http://code.google.com/p/ttf2eot/ -
Web Open Font Format:
woff
the W3C recommendation for webfonts: http://www.w3.org/TR/WOFF/
A converter can be fond here: http://people.mozilla.org/~jkew/woff/ -
and TrueType:
ttf
for Safari and Opera -
(You could add Scalable Vector Graphics:
svg
for older iOS support…)
The bulletproof @font-face Syntax is this:
@font-face {
font-family: 'Vinegar';
src: url('vinegar.eot?') format('embedded-opentype'),
url('vinegar.woff') format('woff'),
url('vinegar.ttf') format('truetype'),
url('vinegar.svg#svgVinegar') format('svg');
}
Further resources:
http://www.paulirish.com/2009/bulletproof-font-face-implementation-syntax/
http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax
You might also want to check out this tool:
https://github.com/zoltan-dulac/css3FontConverter
Related videos on Youtube
Comments
-
useCase over 2 years
I need to use
@font-face
feature and my fonts are in TrueType (TTF) format, so how to convert TTF to OpenType (OTF) format. -
tomsseisums about 13 yearsWouldn't this cause compatibility issues? have heard something like that, but ain't sure...
-
Farzin Zaker about 13 years@Tom I have never seen a compatibility issue with this syntax. it is an old syntax and is supporting by browsers since 2000!
-
tomsseisums about 13 yearsWell, here is an article randsco.com/index.php/2009/07/04/p680 ... scroll down to C'mon, is it Really that Simple? part, there you have it, IE only supporting
*.eot
. Or that's just a myth? -
Eirinn over 10 yearsThe site you link to doesn't seem to convert to OTF.
-
AvL over 10 years
-
Andrei over 9 yearsI guess you need
apt-get install fontforge python-fontforge
or if you are on OS X try stackoverflow.com/a/26313183/179581 -
Agi Hammerthief over 9 yearsThe latest version of IE is 11. Supporting IE 8 or lower is a waste of time unless specifically instructed by a major client. As such, the
url('vinegar.eot?') format('embedded-opentype')
line may be removed. -
Frerich Raabe almost 8 yearsPerfect answer for me, I'm on OS X as well and indeed,
pip install fontforge
didn't work. I already use Homebrew though, so your answer hit the nail on the head for me. :-) -
Leszek about 7 yearsThis is the best answer. All the online converters are worthless as either don't work or require to pay.
-
alez007 almost 6 yearsif anyone else is having problems with this solution, make sure you try this:
fontforge -c "f = fontforge.open(argv[1]); f.generate(argv[2])" ~/Downloads/logo.ttf ~/Downloads/logo1.otf
-
nojhan over 5 yearsGot it to work after adding imports
fontforge -c "import fontforge; from sys import argv; f = fontforge.open(argv[1]); f.generate(argv[2])" font.otf font.ttf
-
Andrei over 5 yearsThings have changed over the years. Feel free to submit it as a separate answer and edit this one to refer to it.
-
jhpratt over 5 yearsYou should disclose that the site is (presumably) yours.