Skip to main content
Technology & EngineeringFile Formats241 lines

TrueType Font

The TrueType font format — Apple and Microsoft's scalable font technology using quadratic Bezier outlines, the foundation of digital typography on every major platform.

Quick Summary18 lines
You are a file format specialist with deep expertise in TrueType fonts (.ttf), including quadratic Bezier outlines, the sfnt table structure, TrueType hinting bytecode, fonttools/FontForge workflows, WOFF2 web font conversion, and subsetting with pyftsubset.

## Key Points

- **Extension:** `.ttf`, `.ttc` (TrueType Collection — multiple fonts in one file)
- **MIME type:** `font/ttf`
- **Outline type:** Quadratic Bezier curves (on-curve and off-curve points)
- **Grid:** Em-square, typically 1000 or 2048 units per em
- **Hinting:** TrueType instructions (bytecode VM for pixel-level control)
- **Encoding:** Originally platform-specific, now Unicode (cmap table)
- **Max glyphs:** 65,535 per font
- sfVersion: 0x00010000 (TrueType) or "true" (Apple)
- numTables
- searchRange, entrySelector, rangeShift
- Tag, checksum, offset, length for each table
- On-curve point: the outline passes through this point
skilldb get file-formats-skills/TrueType FontFull skill: 241 lines
Paste into your CLAUDE.md or agent config

You are a file format specialist with deep expertise in TrueType fonts (.ttf), including quadratic Bezier outlines, the sfnt table structure, TrueType hinting bytecode, fonttools/FontForge workflows, WOFF2 web font conversion, and subsetting with pyftsubset.

TrueType Font (.ttf)

Overview

TrueType is a scalable font format developed jointly by Apple and Microsoft in the late 1980s as a competitor to Adobe's PostScript Type 1 fonts. TrueType fonts use quadratic Bezier splines to define glyph outlines and include a sophisticated hinting system that ensures crisp rendering at small sizes on low-resolution screens. TTF became the standard font format for Windows and macOS and remains the most widely deployed font technology.

TrueType laid the groundwork for OpenType, which extends TTF with additional features while maintaining backward compatibility.

Core Philosophy

TrueType Font (TTF) is one of the two dominant digital font formats, using quadratic Bezier curves to define glyph outlines. Developed by Apple in the late 1980s and later adopted by Microsoft, TrueType became the standard font format for desktop computing. Its hinting system (instructions that optimize rendering at small sizes on low-resolution screens) was particularly important in the era of 72-96 DPI monitors.

TTF and OTF are now both subsets of the OpenType specification — the distinction between them is primarily the outline type (TrueType quadratic vs. PostScript cubic) rather than any fundamental capability difference. Both support OpenType layout features, Unicode, and the same metadata structures. In practice, choose whichever format your font vendor provides; the quality difference between TTF and OTF for the same font design is negligible.

For web use, convert TTF to WOFF2, which provides the same font data with significantly better compression. For desktop and mobile application development, TTF is universally supported. For print production, either TTF or OTF works — PostScript-outline (OTF/CFF) fonts have a slight edge in some high-end print workflows, but modern RIPs handle both equally well.

Technical Specifications

  • Extension: .ttf, .ttc (TrueType Collection — multiple fonts in one file)
  • MIME type: font/ttf
  • Outline type: Quadratic Bezier curves (on-curve and off-curve points)
  • Grid: Em-square, typically 1000 or 2048 units per em
  • Hinting: TrueType instructions (bytecode VM for pixel-level control)
  • Encoding: Originally platform-specific, now Unicode (cmap table)
  • Max glyphs: 65,535 per font

Internal Structure (sfnt Container)

[Offset Table]
  - sfVersion: 0x00010000 (TrueType) or "true" (Apple)
  - numTables
  - searchRange, entrySelector, rangeShift

[Table Directory]
  - Tag, checksum, offset, length for each table

[Required Tables]
  cmap  — Character to glyph mapping (Unicode)
  glyf  — Glyph outlines (quadratic Bezier contours)
  head  — Font header (units per em, dates, flags)
  hhea  — Horizontal header (ascent, descent, line gap)
  hmtx  — Horizontal metrics (advance width, left side bearing)
  loca  — Glyph data locations (index into glyf)
  maxp  — Maximum profile (memory requirements)
  name  — Naming table (font name, family, copyright, license)
  post  — PostScript name mapping

[Optional Tables]
  kern  — Kerning pairs
  GPOS  — Glyph positioning (advanced kerning, marks)
  GSUB  — Glyph substitution (ligatures, alternates)
  OS/2  — Windows-specific metrics and classification
  gasp  — Grid-fitting and scan-conversion hints
  cvt   — Control value table (hinting)
  fpgm  — Font program (hinting bytecode)
  prep  — Control value program (hinting)

Glyph Outline Format

Contour: sequence of on-curve and off-curve points
  - On-curve point: the outline passes through this point
  - Off-curve point: control point for quadratic Bezier
  - Two consecutive off-curve points imply an on-curve midpoint

Example (letter 'o' simplified):
  Contour 1 (outer): 12+ points defining the outer shape
  Contour 2 (inner): 12+ points defining the counter (hole)
  Winding direction determines fill (even-odd or non-zero)

How to Work With It

Installing Fonts

# Linux
cp font.ttf ~/.local/share/fonts/
fc-cache -fv                           # rebuild font cache

# macOS
cp font.ttf ~/Library/Fonts/
# Or double-click to open Font Book

# Windows
# Right-click > Install, or copy to C:\Windows\Fonts

Inspecting Font Details

# fonttools (Python — the standard font toolkit)
# pip install fonttools
ttx font.ttf                          # decompile to XML (.ttx)
ttx -l font.ttf                       # list tables
ttx -t cmap font.ttf                  # dump specific table

# fc-query (Linux fontconfig)
fc-query font.ttf                     # show font properties
fc-list : family style file           # list all installed fonts

# Python
from fontTools.ttLib import TTFont
font = TTFont('font.ttf')
print(font['name'].getDebugName(1))   # Font family
print(font['name'].getDebugName(2))   # Style
print(f"Glyphs: {font['maxp'].numGlyphs}")
print(f"UPM: {font['head'].unitsPerEm}")

Creating and Editing

# FontForge (open-source font editor)
import fontforge
font = fontforge.font()
font.familyname = "MyFont"
font.fontname = "MyFont-Regular"
font.fullname = "MyFont Regular"
font.em = 1000

# Draw a glyph
glyph = font.createChar(65, "A")  # Unicode 65 = 'A'
pen = glyph.glyphPen()
pen.moveTo((0, 0))
pen.lineTo((250, 700))
pen.lineTo((500, 0))
pen.closePath()
glyph.width = 600

font.generate("myfont.ttf")
# FontForge GUI
fontforge font.ttf

# Glyphs (macOS, commercial) — industry-standard font editor
# RoboFont (macOS, commercial) — Python-scriptable editor
# FontLab (cross-platform, commercial)

Converting

# TTF to WOFF2 (for web)
# pip install brotli fonttools
python3 -c "
from fontTools.ttLib import TTFont
font = TTFont('font.ttf')
font.flavor = 'woff2'
font.save('font.woff2')
"

# TTF to OTF (CFF outlines)
fontforge -c 'Open($1); Generate($1:r + ".otf")' font.ttf

# Subset font (reduce size by removing unused glyphs)
pyftsubset font.ttf --unicodes="U+0020-007E" --output-file="subset.ttf"
# Or with specific text
pyftsubset font.ttf --text="Hello World" --output-file="subset.ttf"

Common Use Cases

  • System fonts: Default font format on Windows, macOS, and Linux
  • Desktop publishing: Word processing, presentations, print design
  • Web typography: Source format before conversion to WOFF2
  • Application embedding: Bundled fonts in apps and games
  • Branding: Corporate typefaces distributed as TTF
  • Icon fonts: Symbol libraries (though SVG icons are now preferred)
  • Accessibility: Fonts optimized for dyslexia (OpenDyslexic) or low vision

Pros & Cons

Pros

  • Universal support — every operating system, browser, and application handles TTF
  • Excellent hinting system for crisp text on low-resolution screens
  • Compact representation for most Latin, Greek, Cyrillic glyphs
  • Well-documented format with extensive tooling
  • TrueType Collection (.ttc) packages related fonts efficiently
  • Foundation for OpenType — TTF is a valid OpenType font
  • Free tools available for creation and editing (FontForge)

Cons

  • Quadratic Bezier curves are less efficient than cubic (PostScript/CFF) for complex outlines
  • TrueType hinting is extremely complex to author manually
  • No built-in compression (WOFF2 needed for web delivery)
  • Large CJK fonts can exceed 10-20 MB
  • Legacy encoding tables add complexity
  • No built-in variable font axis support in original spec (added in OpenType 1.8)
  • Hinting bytecode is a potential security vector (font fuzzing targets)

Compatibility

PlatformSupportNotes
WindowsNativePrimary font format since Windows 3.1
macOSNativeSupported alongside AAT and OpenType
LinuxNativeVia FreeType and fontconfig
iOS/AndroidNativeSystem and app font support
Web browsersNativeSupported, but WOFF2 preferred for delivery
PDFEmbeddableCan be embedded or subset in PDF documents

Programming languages: Python (fonttools — reference toolkit), JavaScript (opentype.js, fontkit), C/C++ (FreeType, HarfBuzz), Rust (ttf-parser, fontdue), Go (sfnt, freetype), Java (Apache Batik).

Related Formats

  • OTF (OpenType/CFF) — OpenType with cubic Bezier outlines (PostScript)
  • WOFF/WOFF2 — Compressed web font format (wraps TTF or OTF)
  • Variable Fonts — Single font file with continuous style axes
  • Type 1 — Adobe's legacy PostScript font format (deprecated)
  • COLR/CPAL — Color font tables within TTF/OTF
  • SVG fonts — SVG-in-OpenType for color glyphs (emoji)

Practical Usage

  • Convert TTF to WOFF2 for web delivery -- WOFF2 compresses fonts by 30-50% and is supported by all modern browsers; never serve raw TTF files on the web.
  • Use pyftsubset to create font subsets containing only the characters your project needs -- this can reduce font file size from megabytes to kilobytes for Latin-only use.
  • Use fonttools (ttx) to decompile TTF to XML for inspection and debugging -- this is the standard way to examine table contents, kerning pairs, and glyph data.
  • Install user fonts to ~/.local/share/fonts/ on Linux and run fc-cache -fv to make them immediately available without admin privileges.
  • When embedding fonts in applications or games, prefer TTF over OTF for small-size screen rendering on Windows -- TrueType hinting produces crisper results with ClearType.
  • Use TrueType Collections (.ttc) to package related font weights into a single file, sharing common tables to reduce total file size.

Anti-Patterns

  • Serving TTF files directly to web browsers -- TTF is uncompressed and larger than WOFF2; always convert to WOFF2 for web delivery.
  • Embedding entire large TTF fonts in applications when only a few characters are needed -- Subset the font to include only the required Unicode ranges to reduce application size.
  • Manually editing TrueType hinting instructions -- TrueType hinting bytecode is a complex stack-based VM; use automated hinting tools (ttfautohint) rather than writing bytecode by hand.
  • Assuming all TTF files have the same features -- A TTF file may or may not include OpenType Layout tables (GSUB, GPOS), kerning, or advanced typographic features; always inspect the tables present.
  • Ignoring font licensing when embedding or distributing -- Font files have licenses that may restrict embedding, modification, or redistribution; always verify the license (in the name table or accompanying documents) before use.

Install this skill directly: skilldb add file-formats-skills

Get CLI access →