Convert .otf to .ttf Font on Ubuntu
Monday February 05th 2007, 19:41h
Filed under: FLOSS, Linux, Ubuntu

Finally, after testing several programs such as Fondu or FontForge, I found a nice script by Thomas Maier and was able to create a TrueType font out of a OpenType one (e.g. because OpenOffice.org doesn’t support .otf) by using FontForge:

#!/usr/local/bin/fontforge
# Quick and dirty hack: converts a font to truetype (.ttf)
Print("Opening "+$1);
Open($1);
Print("Saving "+$1:r+".ttf");
Generate($1:r+".ttf");
Quit(0);

Save the script as otf2ttf.sh and type:

fontforge -script otf2ttf.sh FONTNAME.otf

If you want to convert many .otf fonts in a directory to .ttf fonts, type (thanks sw!):

for i in *.otf; do fontforge -script otf2ttf.sh $i; done


43 Comments so far
Leave a comment

I tried this out of curiosity on AdobeSongStd-Light.otf (can be found inside ftp://ftp.fedora.cn/pub/fedora-cn/linux/6/i386/acroread-fonts-chs-7.0.0-1.fc6.y0.i386.rpm)

and got:
Copyright (c) 2000-2006 by George Williams.
Executable based on sources from 11:29 20-Dec-2006.
otf2ttf:3 Unexpected character � (128)

No ttf file was created. *shrug*

Comment by Wesley Tanaka 06.26.07 @ 10:55h

The “Unexpected character” error is because the script example has those fancy-looking (but not very functional) left & right quotation marks. Replace them with normal quotes and the script will work just fine.

Comment by Adam 07.12.07 @ 22:01h

Thanks Adam for your reply! Wordpress changed the quotation marks automatically. So good to know: It’s a feature, not a bug ;)

Comment by matthias 07.15.07 @ 18:21h

This just worked for me- it created the .ttf file and the file appears to be fine. I’m on Ubuntu feisty using Open Office and this is the way to use your otf files. Lots of stuff on Ubuntu can read the otf files- but Open Office does not yet.

Note the comment about the special quotes above if you cut and paste. You need regular quotes, single or double.

Thank you for posting this- it was really helpful.

Comment by William K 08.19.07 @ 5:15h

Thank you so much for this tip! I’ve been looking on how to do this for a while now. This worked perfectly (after changing those fancy quotes) on my Mac.

Comment by Atso 08.23.07 @ 4:30h

Is there a way to use this script to convert multiple elements? I tried to use *.otf instead of FONTNAME.otf but it did not work…

Comment by Hector 10.17.07 @ 17:38h

A good way to convert more than one font is this way (under Linux):

find . -name *.otf -exec fontforge -script /home/xl/bin/otf2ttf.sh {} \;

Comment by Axel 12.04.07 @ 0:24h

Maybe this way:
for i in *.otf; do fontforge -script otf2ttf.sh $i; done

Comment by sw 12.04.07 @ 18:00h

And why not create a script called otf2ttf with this inside:
#!/bin/bash
fontforge -script /usr/bin/script-otf2ttf.sh $1
And then:
ls *.otf | xargs -n 1 otf2ttf
;-)
I describe this on my blog post: http://lazza.wordpress.com/2007/12/04/convertire-i-font-opentype-in-font-truetype/
(italian)

Comment by Lazza 12.07.07 @ 13:29h

My thanks. I spent an entire day trying to convert one of these things so that it would work properly with Java.

The script also works in the X-Window Terminal running Cygwin on Windows.

Nice.

Comment by Aurix 03.17.08 @ 2:42h

Just a note, if you get error messages like this:
File “script”, line 2
Print(”Opening “+$1);
^
SyntaxError: invalid syntax

Run this command before running the script above:
export FONTFORGE_LANGUAGE=ff

Comment by Keccs 06.11.08 @ 18:25h

Hi there,

While this script converts fonts ok, the resulting TTFs seem to lack e.g. kerning information. You can try this e.g. with the CM Unicode fonts or, if you have Adobe Reader installed, with Minion Pro, which at least in the past came with it.

Comment by szal 07.15.08 @ 15:15h

Nice one.
I installed fontforge on my openSuse and it ran smoothly.
Thanks!

Comment by Jack 07.23.08 @ 16:37h

did this script will convert ttf from Japaneses otf font?

Comment by Tef 09.26.08 @ 3:26h

This helped immensely–thanks!

Comment by Bobble 10.03.08 @ 2:59h

thank you so much :)

Comment by AlexWorX 11.20.08 @ 23:28h

Very good article

Comment by Blog 12.01.08 @ 7:41h

Very good article. Thanks!

Comment by secangkirkopipanas 12.02.08 @ 2:59h

Thanks, you rock!

Comment by HarveyJ 12.04.08 @ 20:45h

question - from at designer. (not a programmer) how do I run the script? and where do I type this sentence? fontforge -script otf2ttf.sh FONTNAME.otf

I save the script as you describe in notepad - as otf2ttf.sh, same folder as the font - but have no idea how to run til script on the font?

Thanks

Comment by JAM 03.02.09 @ 17:43h

Hi Jam

Use Google: http://www.google.ch/search?q=use+of+terminal

Best, Matthias

Comment by matthias 03.02.09 @ 17:54h

Hi!
When I run the script under cyngwin I get the following:
$ fontforge-script otf2ttf
bash: fontforge-script: command not founds

Comment by Dominique 03.19.09 @ 8:37h

Thanks a lot! Very useful script.

Comment by Max 03.20.09 @ 10:26h

rocks :D added to ‘nautilus-action-config’ for GUI..

Comment by mrwn 03.29.09 @ 0:40h

Thank you very much! This little script rocks indeed!

Comment by kajivar 04.01.09 @ 18:24h

Just out of curiosity, why do you only mention Ubuntu here. This will work in any Linux distribution.

Before there was Ubuntu, there was Debian, Fedora, Mandriva, RedHat, Slackware, SUSE and several dozen other distributions. As long as you have fontforge installed, this will work in any of them.

Please stop treating Ubuntu as if it were the only Linux distribution around.

Thank you.

Comment by Scott 07.03.09 @ 16:35h

Hello.
I have tried your interesting and useful script but I canot get it to work with a font.
Here is what I get:
Copyright (c) 2000-2008 by George Williams.
Executable based on sources from 00:29 GMT 29-Apr-2008.
Library based on sources from 20:49 GMT 30-Apr-2008.
Opening HiraMinPro-W6.otf
The following table(s) in the font have been ignored by FontForge
Ignoring ‘DSIG’ digital signature table
Ignoring ‘VORG’ vertical origin table
Ignoring ‘Zapf’ glyph reference table
This font contains both a ‘mor[tx]’ table and a ‘GSUB’ table.
FF will only read feature/settings in ‘morx’ which do not match features
found in ‘GSUB’.
Warning: Mac string is a subset of the Windows string in the ‘name’ table
for the Family string in the English (US) language.
Warning: Mac and Windows entries in the ‘name’ table differ for the
Styles (SubFamily) string in the language English (US)
Mac String: W6
Windows String: Regular
Warning: Mac and Windows entries in the ‘name’ table differ for the
Fullname string in the language English (US)
Mac String: Hiragino Mincho Pro W6
Windows String: HiraMinPro-W6
Warning: Mac string is a subset of the Windows string in the ‘name’ table
for the Copyright string in the Japanese language.
Warning: Mac string is a subset of the Windows string in the ‘name’ table
for the Family string in the Japanese language.
Warning: Mac and Windows entries in the ‘name’ table differ for the
Styles (SubFamily) string in the language Japanese
Mac String: W6
Windows String: Regular
Saving HiraMinPro-W6.ttf

What should I do?
Cheers

Comment by Clemens 08.18.09 @ 10:51h

#!/usr/bin/fontforge -lang=ff
i=1;
while ( i<$argc )
Open($argv[i]);
Print(”Saving ” + $argv[i] + “as ” + $argv[i] + “.ttf”);
Generate($argv[i] + “.ttf”);
i = i+1;
endloop
Quit(0);

Comment by Schlaegel 10.11.09 @ 6:54h

My last comment is a script almost ripped out of the fontforge scripting guide. It can handle multiple fonts at a time, without a helper script. This should help it deal with odd file-names better.
Save it as otf2ttf. Then make it executable with, “chmod +x otf2ttf”.
#!/usr/bin/fontforge -lang=ff
i=1;
while ( i<$argc )
Open($argv[i]);
Print("Saving " + $argv[i] + "as " + $argv[i] + ".ttf");
Generate($argv[i] + ".ttf");
i = i+1;
endloop
Quit(0);

Comment by Schlaegel 10.11.09 @ 6:57h

Thanks…..

Comment by Chetan 11.05.09 @ 3:52h

Hm, this works for me if e.g. 10 otf fonts are in one directory and I want to convert them to ttf.
But is it possible to scan a whole directory with subdirs for any kind of font and convert them with a selectable format to a new directory?
This would be the ultimate solution!!!

Comment by TheFontler 01.05.10 @ 16:17h

OpenOffice 3.2 include support for .otf

Comment by Gary 01.14.10 @ 18:32h

:)

Works nicely. Thanks a million. I’ll be using the .ttf files to cater to the unholy IE. :S :)

Comment by Nils N. H. 02.14.10 @ 12:25h

Works perfectly on Ubuntu 9.10. Thank’s so much!

Note that for converting many files, I had to copy the otf2ttf.sh script in the repertory with the otf files although I had previously copied it in /usr/local/bin.

Comment by Epictete 03.11.10 @ 23:03h

The code for SUSE is:
#!/usr/bin/fontforge
truetype (.ttf)
Print("Opening "+$1);
Open($1);
Print("Saving "+$1:r+".ttf");
Generate($1:r+".ttf");
Quit(0);

Also I can’t do multiple file type change on suse help me

Comment by Anonymous 04.14.10 @ 1:11h

This is great!

this script saved my life. I had font named DiavloBLACK in otf format and I couldnt use it in Corel Draw (in VBOX Win XP image) althow the font navigator did recognized it and other windows apps. I used your great script and ttf format is recognized now, but i got this output from script (FF), maybe it can help someone in similar situation:

This font contains both a ‘kern’ table and a ‘GPOS’ table.
The ‘kern’ table will only be read if there is no ‘kern’ feature in ‘GPOS’.
Warning: Mac string is a subset of the Windows string in the ‘name’ table
for the Family string in the English (US) language.
Warning: Mac and Windows entries in the ‘name’ table differ for the
Styles (SubFamily) string in the language English (US)
Mac String: Black
Windows String: Regular
Warning: Mac and Windows entries in the ‘name’ table differ for the
Fullname string in the language English (US)
Mac String: Diavlo Black Regular
Windows String: DiavloBlack-Regular

Comment by kreso 07.11.10 @ 10:44h

3 years latter, this is still useful :)
Many thanks !

Comment by mike 07.27.10 @ 17:20h

Thanks for that script. I have actually try it and the process is good. I’m looking forward to see other scripts too that can really help me in my blog.

Comment by Naples 08.20.10 @ 9:31h

I just tried this on Ubuntu 10.04, and it worked like a charm. Thanks!

Comment by Deb 09.10.10 @ 5:35h

thanks! i was battling with a couple of OTF fonts and getting no where. this worked perfectly and both are now installed. :) :)

Comment by matt mcinvale 10.12.10 @ 19:05h

I second Mike’s comment!

Comment by Marc van Dongen 10.19.10 @ 11:11h

hi, can u plese convert for me adobe arabic fonts for use in my ubuntu 5.04? it will make me so happy if you will have some time to do that for me.
regards from baku, aze
tefsir / yahoo.com or elcin / isam.org.tr

Comment by elcin 02.11.11 @ 17:17h


#!/bin/sh
# Converts a font to truetype (.ttf)
for i in *.otf; do fontforge -lang=ff -c "Open(\"$i\");Generate(\"$i\":r+\".ttf\");Quit(0);" $i; done

Comment by Artūrs 12.25.15 @ 9:38h



Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)