Batch Export FontForge Glyphs as Images
Yes, you can batch export all glyphs as images using FontForge, though doing so requires utilizing FontForge’s built-in scripting engine rather than a single menu button in the graphical interface. By running a simple Python script within FontForge, you can automatically iterate through every character in a font file and export it to an image format such as SVG, PNG, or EPS in seconds.
Method 1: Using the Internal Python Script Tool
The quickest method without leaving the FontForge interface is using the Execute Script window.
- Open your font in FontForge.
- Navigate to File > Execute Script... in the top menu bar.
- In the script window, set the drop-down menu to Python.
- Paste the following script:
import fontforge
import os
font = fontforge.activeFont()
output_dir = "exported_glyphs"
if not os.path.exists(output_dir):
os.makedirs(output_dir)
for glyph in font.glyphs():
# Only export glyphs that contain actual outlines
if glyph.isWorthOutputting():
filename = f"{output_dir}/{glyph.glyphname}.png"
glyph.export(filename)- Click OK. FontForge will generate the images in a
folder named
exported_glyphsinside your current working directory.
Method 2: Running a Standalone Terminal Script
If you have FontForge installed on your system and prefer command-line execution, you can run an automated script across an entire font file without opening the GUI.
Create a file named export_glyphs.py with the following
code:
import fontforge
import sys
import os
if len(sys.argv) < 3:
print("Usage: fontforge -script export_glyphs.py <font-file> <output-folder>")
sys.exit(1)
font_path = sys.argv[1]
output_dir = sys.argv[2]
if not os.path.exists(output_dir):
os.makedirs(output_dir)
font = fontforge.open(font_path)
for glyph in font.glyphs():
if glyph.isWorthOutputting():
# Export as SVG; change extension to .png or .eps if desired
filename = os.path.join(output_dir, f"{glyph.glyphname}.svg")
glyph.export(filename)
font.close()
print("Batch export completed successfully.")Run the script from your terminal using:
fontforge -script export_glyphs.py /path/to/font.otf /path/to/output_folderChoosing the Output Format
FontForge automatically detects the image format based on the file
extension you specify in the glyph.export() function:
.svg: Best for vector graphics, preserving full bezier curves and scalability..png: Produces raster images. You can control the pixel dimension by setting the point size or pixel size using FontForge preference functions prior to export..eps: Ideal for Encapsulated PostScript workflows in traditional vector design applications.