My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Demo  
Simple ttf2eot Example
Featured, Phase-Deploy
Updated Feb 4, 2010 by tav...@gmail.com

Introduction

Simple demonstration of ttf2eot usage.

Details

First create the output file

$ ttf2eot < input.ttf > output.eot

If that worked, you can specify the file in your CSS.

<style>
@font-face { 
    font-family: "testing";
    src: url("output.eot");
}
</style>
<div style="font-family: testing">
Hello, World!
</div>

Only IE understands this format, other browsers (Safari 3.x, Firefox 3.1.x, Chrome 2.x) are likely to adopt src: url("foo.ttf") format("truetype") instead.

You can use conditional comments to specify both formats, simply provide the font in both EOT and TTF format, then use conditional comments to make IE see the EOT version.

<style>
@font-face { 
    font-family: "testing";
    src: url("output.ttf") format("truetype");
}
</style>
<!--[if IE]>
    <style>
    @font-face { 
        font-family: "testing";
        src: url("output.eot");
    }
    </style>
<![endif]-->
<div style="font-family: testing">
Hello, Multiple Browser World!
</div>

This should work in IE6, IE7, IE8, Safari 3/4 and Firefox 3.1+

Note for Windows Users

If you're a Windows user - this is probably not what you're looking for.

You will probably feel more comfortable using "WEFT", Microsoft's own utility for handling EOT. ttf2eot is primarily for UNIX users who want to make font embedding work for IE without using Microsoft software.

However, if you're certain you do wish to use ttf2eot, a command line windows binary is provided. It is used like so:

C:\>ttf2eot.exe c:\windows\fonts\arial.ttf c:\output.eot

C:\>dir output.eot
 Volume in drive C has no label.
 Volume Serial Number is E4EC-5386

 Directory of C:\

30/04/2009  21:41           367,270 output.eot
               1 File(s)        367,270 bytes
               0 Dir(s)  51,782,295,552 bytes free

C:\>

Please note, It is unlikely the author will be able to help with Windows related questions.

Comment by hob...@gmail.com, Jul 6, 2009

@font-face's src property takes a comma-separated list of sources, so I don't think you need to resort to conditional comments in this case. Try the following instead:

    @font-face {
        font-family: "testing";
        src: url("output.eot"),
             url("output.ttf") format("truetype");
    }
Comment by chris.si...@gmail.com, Jul 8, 2009

Unfortunately, IE (6 and 8 tested) doesn't seem to honour the list of sources. I did my own testing just now (involving lots of frustration).

It doesn't work regardless of the order of the sources. So, it's back to conditional comments. :(

Comment by chris.si...@gmail.com, Jul 8, 2009

IE will ignore font-face declarations with any format() hints:

http://hacks.mozilla.org/2009/06/beautiful-fonts-with-font-face/

Comment by impall...@gmail.com, Jul 17, 2009

Just make 2 font face declarations, like this:

@font-face{
	font-family: 'MuseoSans500'; 
	src: url('MuseoSans500.eot');
}
@font-face{
	font-family: 'MuseoSans500'; 
	src: url('MuseoSans_500.otf') format('opentype');
}

Im doing it this way on my site and works like charm. Have a look: www.pabloimpallari.com.ar

Comment by siryi...@gmail.com, Jul 28, 2009

Thanks so much for this. Microsoft's WEFT just wouldn't convert the font I wanted, and this is so much easier then WEFT.

I am using the same font as impallari no less, hope it doesn't turn into Verdana :P

Comment by ken...@gmail.com, Aug 1, 2009

Thanks this is a must !

Comment by iphonete...@gmail.com, Aug 3, 2009

I compiled this on my iMac (OS X 10.5.7). But when I try to convert a fon all it gives me when I try to make an .eot is "command not found".

Comment by shoveme...@gmail.com, Aug 5, 2009

I had horrid trouble with my converted opentype font, but I found the problem and posted a solution: http://karoshiethos.com/2009/08/05/creating-eot-files-with-ttf2eot/

Comment by skim...@gmail.com, Aug 25, 2009

Confirming Impallari's comment that:

1) It's not necessary to use conditional comments for the IE's (IE6,7 & 8), 2) Just make 2 @font-face declarations;

It is imperative that the IE declaration come FIRST. This isn't for IE, but rather, for the 'modern' browsers (i.e., FFx 3.5+, Safari, etc.) If the EOT file is last, those browsers will try to load the EOT file and fail.

Here's a more detailed write-up on how to achieve cross-browser font embedding: http://randsco.com/index.php/2009/07/04/cross_browser_font_embedding

Cheers

Comment by Fliawebd...@gmail.com, Sep 4, 2009

I can't get font-face to work on ie

this is what i got , declaring eot before for ie browsers

@font-face {

font-family: "trade"; src: url("../type/LTe50543.eot");
} / EOT file for IE /

@font-face {

font-family: "trade"; src: url("../type/LTe50543.ttf") format("TrueType?"); }

works in all other browser that support @font-face

Comment by alecgo...@gmail.com, Sep 11, 2009

for people who want to drag and drop multiple font files and create EOT files with the same name, here is a batch file. Just put it in the same directory as ttf2eot.exe and drag fonts on to the .bat file.

@echo off
if [%1]==[] goto :eof
:loop
ttf2eot %1 "%~dpn1.eot"
shift
if not [%1]==[] goto loop
Comment by mburu.sa...@gmail.com, Oct 17, 2009

This tool is so much better than WEFT, it wants your email address to use it... I thought that was ridiculous... in mere minutes I was able to get this going and done..

Thanks!! (I don't use the double ! marks without reason)

Comment by sara.tu...@gmail.com, Oct 26, 2009

You are the greatest!

Comment by chai...@gmail.com, Dec 13, 2009

WOW excellent tool i love this

Comment by ed...@web.de, Dec 31, 2009

Batch file from Sep 11, 2009 won't work if ttf2eot.exe isn't within your path environment. Name the batch ttf2eot.cmd and place it in the same directory as ttf2eot.exe and everything is fine:

@set prog=%~pn0.exe @if [%1]== goto :eof :loop @%prog% %1 "%~dpn1.eot" @shift @if not [%1]== goto loop

Why do I have to register at google with a valid email adress to write this comment? See above: mburu.samuel, Oct 17, 2009. The email at WEFT isn't checked.

Comment by rockclim...@gmail.com, Jan 4, 2010

Hi, is there a way to convert this code into PHP ??

Comment by fun...@gmail.com, Jan 12, 2010

it would be great if you could replace the lzcomp compressor by LZMA http://tukaani.org/lzma/

Comment by okanta...@gmail.com, Mar 6, 2010

i have problems with windows...how can i get the ".c" and ".h" files to ".exe" without any programming environment?! got anybody a link?

Comment by camilovi...@gmail.com, Mar 29, 2010

it doens work on Windows 7

Comment by sova-art...@yandex.ru, May 2, 2010

WEFT do smaller files than ttf2eot for me.

Comment by ivan.tod...@gmail.com, Jun 30, 2010

Batch file won't work with Windows 7 because Windows 7 allows you to have spaces in your path lines. ( Instead of "Progra~1" it uses "Program Files" )

Comment by john.gor...@gmail.com, Jul 21, 2010

I tried to convert Clarendon TTF font and it died with the return error, “Unknown error parsing input font, m"

Comment by adamsak...@gmail.com, Nov 10, 2010

dad.bat (drag and drop)

code: @echo off set path=%~d0%~p0 ttf2eot.exe "%~dpn1.ttf" "%~dpn1.eot"

Comment by aladjev....@gmail.com, Dec 1, 2010

be serious! =)

install: ttf2eot

cp ttf2eot /usr/bin

ttf2eot: OpenTypeUtilities.o ttf2eot.o

g++ -O3 -o $@ $^

strip $@

OpenTypeUtilities.o: OpenTypeUtilities.cpp

g++ -O3 -c -o $@ $^

ttf2eot.o: ttf2eot.cpp

g++ -O3 -c -o $@ $^

clean:

rm -f ttf2eot OpenTypeUtilities.o ttf2eot.o

Comment by stu...@ishelomi.com, Dec 12, 2010

Hi, I downloaded the ttf2eot tool, and got a folder with: OpenTypeUtilities?.cpp OpenTypeUtilities?.h ttf2eot.cpp Etc.

I have FontForge? and x11 installed, on my Mac OS X 10.4.x. MacBookPro?. Also have MacPorts? installed

Can someone please help using this script, I am a graphic designer not a programmer.

A step by step ‘lead by the nose’ will be appreciated.

thanks

Comment by adamika2...@freemail.hu, Dec 14, 2010

THX!

Comment by eduardoi...@gmail.com, Feb 6, 2011

I really tried to get this working on OS X Snowleopard. Your makefile is like "aladjev....@gmail.com" points out, not the best one. So I made a new makefile. Make fine, moved to local bin and tried it out. I got a ton of output during runtime, then nothing happen. It did not make any eot file of that font.

If anyone managed to get this working on Snowleopard, please drop me a line. I am out of time to solve this problem, because of delivery. I can´t understand why no one have made a OET converter app for mac.

Output:

21?LP?%syrRapScript_FreeRegularNVersion 1.000;PS 001.000;hotconv 1.0.38RapScript_FreeOTTO ?CFF ??aEp?OS/2???`cmap???i??head??7??6hhea :???$hmtxpf/? maxpHP?namee/ONOpost??2P rys%_<???Mz1?Mz1?6?:?0??V6?6???HPH????????2??pyrs@ ??V0??6 !?88FM8'8? ? ??

R
??R8F p? ? ? &? ? N? ? M k k ?
8 ?
<

... and so on

Comment by uip...@gmail.com, Jun 20, 2011

brew install ttf2eot

Comment by jelak...@gmail.com, Jun 27, 2011

i use parallel desktops on my macOS so i can test all the browsers :) so i used ttf2oet on my virtual windows machine

Comment by Coli...@gmail.com, Jan 12, 2012

I don't think I missed anything,(except how to program in C/C++). Trying to build I get:

~/ttf2eot-0.0.2-2$ make
g++    -c -o OpenTypeUtilities.o OpenTypeUtilities.cpp
OpenTypeUtilities.cpp:227:18: warning: multi-character character constant [-Wmultichar]
OpenTypeUtilities.cpp:247:18: warning: multi-character character constant [-Wmultichar]
OpenTypeUtilities.cpp:257:18: warning: multi-character character constant [-Wmultichar]
OpenTypeUtilities.cpp: In function âbool getEOTHeader(unsigned char*, size_t, std::vector<unsigned char>&, size_t&, size_t&, size_t&)â:
OpenTypeUtilities.cpp:197:41: error: expected primary-expression before â,â token
OpenTypeUtilities.cpp:197:43: error: âtablesâ was not declared in this scope
OpenTypeUtilities.cpp:197:49: error: âoffsetofâ was not declared in this scope
OpenTypeUtilities.cpp:202:41: error: expected primary-expression before â,â token
OpenTypeUtilities.cpp:202:43: error: âtablesâ was not declared in this scope
OpenTypeUtilities.cpp:202:49: error: âoffsetofâ was not declared in this scope
OpenTypeUtilities.cpp:259:70: error: expected primary-expression before â,â token
OpenTypeUtilities.cpp:259:72: error: ânameRecordsâ was not declared in this scope
OpenTypeUtilities.cpp:259:83: error: âoffsetofâ was not declared in this scope
OpenTypeUtilities.cpp:265:74: error: expected primary-expression before â,â token
OpenTypeUtilities.cpp:265:76: error: ânameRecordsâ was not declared in this scope
OpenTypeUtilities.cpp:265:87: error: âoffsetofâ was not declared in this scope
make: *** [OpenTypeUtilities.o] Error 1

Not sure why it works for others and not me, possibly that I don't have X11 on this machine. What am I doing wrong?

Comment by dago...@gmail.com, Jan 31, 2012
No se ingles y creo que no saben español: Pero doy gracias porque el programa funcionó bien.

Muchas Gracias!


Sign in to add a comment
Powered by Google Project Hosting