How do I convert a TTF into individual PNG character images?

Solution 1:

You can use Python with FontForge, it has a Python 2.7 interpreter.

On Windows: after installing FontForge, locate the "bin" in installation path and add it to the Windows system path, in my case it is:

c:\Program Files (x86)\FontForgeBuilds\bin\

This dir contains ffpython.exe so after adding it to PATH you can directly run a .py script in console.

> ffpython myscript.py

To export all glyphs you can use this simple script:

import fontforge
F = fontforge.open("perpetua.ttf")
for name in F:
    filename = name + ".png"
    # print name
    F[name].export(filename)
    # F[name].export(filename, 600)     # set height to 600 pixels

documentation:
http://fontforge.github.io/python.html#Glyph
http://fontforge.github.io/python.html#Font

Solution 2:

fontforge has switched to a python scripting language. Create a file exportGlyphs.py:

import os
from fontforge import *

font = open(os.sys.argv[1])
for glyph in font:
    if font[glyph].isWorthOutputting():
        font[glyph].export(font[glyph].glyphname + ".png")

Then run fontforge as:

fontforge -script exportGlyphs.py YOURFONT.ttf

Bingo. A whole bunch of .png files for each glyph.