convertFont

March 28, 2026 ยท View on GitHub

Convert font files between popular web and desktop formats using fonttools.

Usage

openGyver convertFont <input-file> [flags]

Prerequisites

fonttools must be installed (Python package).

pip install fonttools brotli zopfli

The pyftsubset command (included with fonttools) must be available in PATH.

Arguments

ArgumentRequiredDescription
input-fileYesPath to the input font file

Flags

FlagShortTypeDefaultDescription
--output-ostring""Output file path (required)
--help-hboolfalseShow help for convertFont

Supported Formats (12)

FormatExtensionDescription
AFM.afmAdobe Font Metrics
CFF.cffCompact Font Format
DFONT.dfontMac Data Fork Font
EOT.eotEmbedded OpenType (IE legacy)
OTF.otfOpenType Font
PFA.pfaPostScript Font ASCII
PFB.pfbPostScript Font Binary
SFD.sfdFontForge Spline Font Database
TTF.ttfTrueType Font
UFO.ufoUnified Font Object
WOFF.woffWeb Open Font Format 1.0
WOFF2.woff2Web Open Font Format 2.0 (Brotli)

Conversion Details

Output FormatTool / Method
WOFFpyftsubset with --flavor=woff --no-subset
WOFF2pyftsubset with --flavor=woff2 --no-subset
TTF / OTFfonttools ttx (XML intermediate)

Examples

# Convert TrueType to WOFF2 for modern web use
openGyver convertFont font.ttf -o font.woff2

# Convert OpenType to WOFF for broader web compatibility
openGyver convertFont font.otf -o font.woff

# Convert WOFF2 back to TrueType
openGyver convertFont font.woff2 -o font.ttf

# Convert TrueType to legacy Embedded OpenType (for old IE)
openGyver convertFont font.ttf -o font.eot

# Convert OpenType to WOFF2
openGyver convertFont font.otf -o font.woff2

# Convert WOFF to TrueType
openGyver convertFont webfont.woff -o desktop.ttf

# Convert TTF to OTF
openGyver convertFont font.ttf -o font.otf

# Convert OTF to WOFF2 for web deployment
openGyver convertFont display.otf -o display.woff2

Notes

  • The input and output formats are auto-detected from file extensions.
  • Both the input and output format must be in the supported formats list.
  • WOFF and WOFF2 conversions use pyftsubset with --no-subset to preserve all glyphs.
  • WOFF2 requires the brotli Python package for Brotli compression.
  • TTF/OTF conversions use fonttools' ttx command which converts via an XML intermediate representation.
  • Not all format combinations may be supported by fonttools. The primary supported output formats are: TTF, OTF, WOFF, WOFF2.