FontForge is a powerful, open-source font editor. This package provides the Python bindings for FontForge, allowing you to create, edit, and convert fonts programmatically.
pip install fontforgeimport fontforge
# Create a new font
font = fontforge.font()
font.familyname = "MyFont"
font.fontname = "MyFont-Regular"
# Create a glyph
glyph = font.createChar(ord('A'))
pen = glyph.glyphPen()
# Draw the glyph...
# Open an existing font
font = fontforge.open("path/to/font.ttf")
# Access glyphs
for glyph in font.glyphs():
print(glyph.glyphname, glyph.unicode)
# Generate output
font.generate("output.otf")- Read/Write Font Formats: OTF, TTF, UFO, Type1, WOFF, WOFF2, and more
- Glyph Editing: Create and modify glyph outlines programmatically
- OpenType Features: Build and manipulate GSUB/GPOS tables
- Font Conversion: Convert between font formats
- Metrics & Kerning: Set sidebearings, create kerning pairs
- Validation: Check fonts for common issues
- Batch Processing: Script operations across multiple fonts
This package installs two Python modules:
fontforge- The main font manipulation modulepsMat- PostScript transformation matrix utilities
import fontforge
import psMat
# Create a transformation matrix (scale 2x)
matrix = psMat.scale(2.0)
# Apply to a glyph layer
glyph.transform(matrix)- Python 3.8 or later
- No additional Python dependencies required
The wheel includes all required native libraries (FreeType, libxml2, etc.).
Pre-built wheels are available for:
- Linux: x86_64, aarch64 (manylinux_2_28)
- macOS: x86_64, arm64 (macOS 11.0+)
- Windows: x86_64
FontForge was designed for interactive use with trusted font files. The codebase has known vulnerabilities, including buffer overruns, that can cause crashes and may be exploitable. Do not process untrusted input without thorough sandboxing.
If no wheel is available for your platform, pip will attempt to build from source. This requires:
- CMake 3.15+
- C/C++ compiler
- FreeType, libxml2, zlib development headers
See the build documentation for details.
This package provides only the Python module. For the full FontForge GUI application, see:
FontForge is licensed under the GPLv3+.