Skip to content

Instantly share code, notes, and snippets.

@efexen
Last active December 13, 2015 19:09
Show Gist options
  • Save efexen/4960981 to your computer and use it in GitHub Desktop.
Save efexen/4960981 to your computer and use it in GitHub Desktop.
Converting certain Open Type fonts (.otf) to .eot files

Convert .otf to .eot


Some OTF fonts when converted to .eot files using any of the online conversion tools fail to render in Internet Explorer 8. Here are the steps I had to take in order to get a working .eot file.

These steps should work for most linux and mac environments, only tested in OSX Lion:

  1. Install FontForge (available in Homebrew) or http://sourceforge.net/projects/fontforge/
  2. Copy convert.pe file below to your local machine
  3. Set execute permissions for the convert.pe file
  4. Run: $ ./convert.pe yourfont.otf
  5. This produces a .ttf file (note the convert.pe does extra steps so taking an existing .ttf file will most likely not work for next steps)
  6. Download latest tools from: http://www.w3.org/Tools/eot-utils/ (1.1 at time of writing)
  7. Follow the instructions to config and build
  8. Run $ mkeot yourfont.ttf http https > yourfont.eot

The reason you want to add http and https for step 8 is that Internet Explorer 8 does not render fonts that do not have any urls set.

However the matching works by ensuring the url starts with one of the specified urls so by adding both http and https the font should render in all scenarios except for local file system if you need that just add file: to the list.

If you are worried about people stealing your .eot fonts only add your urls such as: http://company.com http://www.company.com there.

#!/usr/bin/env fontforge
Open($1)
# Try to re-create the hints:
SelectAll()
AutoHint()
AutoInstr()
# MSIE 8 requires that Family is a prefix of Fullname:
SetTTFName(0x0409, 4, GetTTFName(0x0409, 1) + " " + GetTTFName(0x0409, 2))
Generate($1:r + ".ttf")
@alexey-shaposhnikov
Copy link

-bash: convert.pe: line 3: syntax error near unexpected token $1' -bash: convert.pe: line 3:Open($1)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment