Skip to main content
Technology & EngineeringFile Formats253 lines

OpenType Font

The OpenType font format — the modern standard for digital typography, extending TrueType with PostScript outlines, advanced layout features, and cross-platform support.

Quick Summary18 lines
You are a file format specialist with deep expertise in OpenType fonts (.otf), including CFF/CFF2 PostScript outlines, GSUB/GPOS layout tables, feature tag configuration, fonttools/HarfBuzz workflows, and CSS font-feature-settings for web typography.

## Key Points

- **Extension:** `.otf` (CFF outlines), `.ttf` (TrueType outlines — also OpenType)
- **MIME type:** `font/otf`
- **Outline types:** CFF (cubic Bezier, PostScript) or TrueType (quadratic Bezier)
- **Grid:** Typically 1000 UPM (CFF) or 2048 UPM (TrueType)
- **Max glyphs:** 65,535 per font
- **Layout engines:** GSUB (glyph substitution), GPOS (glyph positioning)
- **Standard:** ISO/IEC 14496-22, also known as "Open Font Format"
- Scripts: Latin, Arabic, Devanagari, CJK, etc.
- Languages: specific rules per language (e.g., Turkish i/I)
- Features: tagged capabilities (liga, kern, smcp, etc.)
- **Professional typography:** Books, magazines, branding with advanced features
- **Web fonts:** Source for WOFF2 conversion with OpenType features
skilldb get file-formats-skills/OpenType FontFull skill: 253 lines
Paste into your CLAUDE.md or agent config

You are a file format specialist with deep expertise in OpenType fonts (.otf), including CFF/CFF2 PostScript outlines, GSUB/GPOS layout tables, feature tag configuration, fonttools/HarfBuzz workflows, and CSS font-feature-settings for web typography.

OpenType Font (.otf)

Overview

OpenType is a font format jointly developed by Microsoft and Adobe, first released in 1996 and later standardized as ISO/IEC 14496-22. OpenType extends TrueType by adding support for PostScript (CFF/CFF2) glyph outlines, advanced typographic features (ligatures, small caps, contextual alternates, swashes), and comprehensive international script support.

The term "OpenType" covers two outline flavors: TrueType outlines (.ttf) and PostScript/CFF outlines (.otf). The .otf extension specifically indicates CFF outlines, which use cubic Bezier curves preferred by type designers. Both share the same sfnt container, table structure, and OpenType Layout features.

Core Philosophy

OpenType Font (OTF) is the modern standard for digital typography, developed jointly by Microsoft and Adobe to unify the competing TrueType (Apple/Microsoft) and PostScript Type 1 (Adobe) font technologies. OTF fonts can contain either TrueType (quadratic) or PostScript (cubic) outlines, but the key innovation is the shared OpenType layout tables that enable advanced typographic features regardless of the outline type.

OTF's advanced typography features — ligatures, stylistic alternates, small caps, contextual swashes, old-style figures, and language-specific forms — are what distinguish it from basic TrueType fonts. These features are defined in the GSUB (glyph substitution) and GPOS (glyph positioning) tables, which applications query to apply sophisticated typography. When choosing fonts for a project, OTF fonts with rich OpenType features enable professional-grade typography in applications that support them.

For web deployment, convert OTF fonts to WOFF2, which applies additional compression (typically 30-50% smaller) without losing any features. Desktop applications and print workflows typically use OTF or TTF directly. When evaluating OTF fonts, check which OpenType features are included — the file extension tells you the container format, not the quality or feature richness of the font inside.

Technical Specifications

  • Extension: .otf (CFF outlines), .ttf (TrueType outlines — also OpenType)
  • MIME type: font/otf
  • Outline types: CFF (cubic Bezier, PostScript) or TrueType (quadratic Bezier)
  • Grid: Typically 1000 UPM (CFF) or 2048 UPM (TrueType)
  • Max glyphs: 65,535 per font
  • Layout engines: GSUB (glyph substitution), GPOS (glyph positioning)
  • Standard: ISO/IEC 14496-22, also known as "Open Font Format"

Key Tables (Beyond TrueType Base)

[Outline Tables]
  CFF / CFF2   — PostScript outlines (cubic Bezier curves)
  glyf + loca  — TrueType outlines (quadratic, if TTF flavor)

[OpenType Layout Tables]
  GSUB — Glyph Substitution
    - Single substitution (small caps: a → ᴀ)
    - Ligature substitution (f + i → fi)
    - Contextual alternates (swash at end of word)
    - Stylistic alternates and sets
  GPOS — Glyph Positioning
    - Kerning (pair and class-based)
    - Mark positioning (diacritics, vowel marks)
    - Cursive attachment (Arabic script)
  GDEF — Glyph Definition (base, mark, ligature classification)

[Script/Language System]
  - Scripts: Latin, Arabic, Devanagari, CJK, etc.
  - Languages: specific rules per language (e.g., Turkish i/I)
  - Features: tagged capabilities (liga, kern, smcp, etc.)

[Optional Tables]
  MATH  — Math typesetting layout
  COLR  — Color glyph layers
  CPAL  — Color palette
  SVG   — SVG glyph outlines (color emoji)
  CBDT/CBLC — Color bitmap glyphs (emoji)
  STAT  — Style Attributes (for variable font families)

OpenType Feature Tags (Common)

TagFeatureExample
ligaStandard ligaturesfi, fl, ff
kernKerningAV spacing adjustment
smcpSmall capsAbc → Aʙᴄ
onumOldstyle numerals1234 → ₁₂₃₄
fracFractions1/2 → ½
swshSwashDecorative alternates
ss01-ss20Stylistic setsAlternative designs
caltContextual alternatesScript-style connections

How to Work With It

Inspecting

# fonttools (Python)
from fontTools.ttLib import TTFont

font = TTFont('font.otf')
print(f"CFF outlines: {'CFF ' in font or 'CFF2' in font}")
print(f"Glyphs: {font['maxp'].numGlyphs}")

# List OpenType features
if 'GSUB' in font:
    gsub = font['GSUB'].table
    for feature in gsub.FeatureList.FeatureRecord:
        print(f"Feature: {feature.FeatureTag}")

# Dump to XML for inspection
# ttx -t GSUB font.otf
# Command-line inspection
otfinfo -f font.otf               # list OpenType features
otfinfo -g font.otf               # list glyph names
otfinfo -i font.otf               # font info
otfinfo -t font.otf               # list tables

# HarfBuzz shape test
hb-shape font.otf "ffi"           # show shaping output
hb-view font.otf "Hello" -o out.png  # render text to image

Using OpenType Features in CSS

/* Enable specific features */
.text {
    font-family: 'MyFont', serif;
    font-feature-settings: "liga" 1, "kern" 1;  /* ligatures, kerning */
    font-feature-settings: "smcp" 1;             /* small caps */
    font-feature-settings: "onum" 1;             /* oldstyle numerals */
    font-feature-settings: "ss01" 1;             /* stylistic set 1 */
    font-feature-settings: "frac" 1;             /* fractions */
}

/* High-level CSS properties (preferred) */
.text {
    font-variant-ligatures: common-ligatures;
    font-variant-caps: small-caps;
    font-variant-numeric: oldstyle-nums tabular-nums;
    font-kerning: auto;
}

Creating

# FontForge (open-source)
fontforge font.otf

# Glyphs (macOS, industry standard for professional type design)
# RoboFont (macOS, Python-scriptable)
# FontLab 8 (cross-platform)
# Generate OTF programmatically
from fontTools.fontBuilder import FontBuilder

fb = FontBuilder(1000, isTTF=False)  # CFF outlines
fb.setupGlyphOrder([".notdef", "A", "B"])
fb.setupCharacterMap({65: "A", 66: "B"})

fb.setupGlyf({})  # Empty for CFF
# ... set up CFF outlines, metrics, names
fb.setupHorizontalMetrics({"A": (600, 50), "B": (650, 60)})
fb.setupNameTable({"familyName": "MyFont", "styleName": "Regular"})
fb.setupOs2()
fb.setupPost()
fb.setupHead(unitsPerEm=1000)

fb.font.save("output.otf")

Converting

# OTF to TTF (convert cubic to quadratic outlines)
fonttools cu2qu font.otf -o font.ttf

# OTF to WOFF2
python3 -c "
from fontTools.ttLib import TTFont
f = TTFont('font.otf'); f.flavor='woff2'; f.save('font.woff2')
"

# Subset (reduce file size)
pyftsubset font.otf --unicodes="U+0000-007F,U+00A0-00FF" --layout-features='kern,liga' --output-file=subset.otf

Common Use Cases

  • Professional typography: Books, magazines, branding with advanced features
  • Web fonts: Source for WOFF2 conversion with OpenType features
  • Multilingual publishing: Complex script support (Arabic, Indic, CJK)
  • Mathematical typesetting: MATH table for equation layout (STIX, Cambria Math)
  • Color fonts: Emoji and decorative color typefaces
  • Corporate identity: Brand fonts with custom ligatures and alternates
  • Accessibility: Fonts with specific OpenType features for readability

Pros & Cons

Pros

  • Advanced typographic features (ligatures, contextual alternates, stylistic sets)
  • Cubic Bezier outlines are more natural for type designers
  • Cross-platform compatibility (Windows, macOS, Linux, web)
  • Comprehensive international script support via OpenType Layout
  • ISO standard with extensive documentation
  • Superset of TrueType — backward compatible
  • Color font support (COLR, SVG, CBDT/CBLC)
  • Variable font technology (OpenType 1.8+)

Cons

  • CFF hinting is less effective than TrueType hinting on Windows at small sizes
  • Feature support varies across applications (not all apps use all features)
  • Complex specification can be difficult to implement fully
  • CFF subsetting is more complex than TrueType
  • Some older applications don't support OTF properly
  • CFF2 (variable font CFF) has limited tool support
  • Font features are invisible to users who don't know about them

Compatibility

PlatformSupportNotes
WindowsFullClearType and DirectWrite, full GSUB/GPOS
macOSFullCore Text, excellent rendering
LinuxFullFreeType + HarfBuzz
iOSFullCore Text
AndroidFullFreeType + HarfBuzz (Minikin)
WebFullAll modern browsers, WOFF2 for delivery
Adobe appsExcellentFull feature support
Microsoft OfficeGoodBasic features, improving

Programming languages: Python (fonttools, fontmake), JavaScript (opentype.js), C/C++ (FreeType for rendering, HarfBuzz for shaping), Rust (read-fonts/skrifa), Go (sfnt).

Related Formats

  • TTF — TrueType with quadratic outlines (also valid OpenType)
  • WOFF/WOFF2 — Compressed web delivery format wrapping OTF/TTF
  • Variable Fonts — Single file with continuous design axes
  • Type 1 — Adobe's legacy PostScript font (deprecated 2023)
  • CFF/CFF2 — The PostScript outline format inside OTF
  • AAT (Apple Advanced Typography) — Apple's pre-OpenType layout system

Practical Usage

  • Convert OTF to WOFF2 for web delivery using fonttools -- WOFF2 provides significantly smaller files while preserving all OpenType features.
  • Use pyftsubset to create subsets containing only the Unicode ranges and layout features your project needs, dramatically reducing file size for web fonts.
  • Use high-level CSS properties (font-variant-ligatures, font-variant-caps, font-variant-numeric) instead of font-feature-settings when possible -- they are more readable and cascade correctly.
  • Use hb-shape (HarfBuzz) to test how text is shaped with specific OpenType features before deploying fonts in production.
  • Inspect OTF internals with ttx (fonttools) to dump tables to XML for debugging feature behavior and glyph coverage.
  • When choosing between OTF (CFF outlines) and TTF (TrueType outlines), prefer OTF for print and high-resolution displays; prefer TTF for small sizes on Windows where ClearType hinting is critical.

Anti-Patterns

  • Ignoring OpenType features when they are available -- Many professional fonts include ligatures, small caps, oldstyle numerals, and contextual alternates that dramatically improve typography; enable them in CSS or application settings.
  • Using font-feature-settings for everything in CSS -- This low-level property does not cascade or compose well; use the higher-level font-variant-* properties whenever the browser supports them.
  • Serving raw OTF files on the web -- OTF files are uncompressed; always convert to WOFF2 for web delivery, which typically reduces file size by 30-50%.
  • Assuming all applications support all OpenType features -- Feature support varies widely; Microsoft Word, Google Docs, and web browsers each support different subsets of OpenType Layout features.
  • Embedding entire multi-weight font families without subsetting -- A full font family with multiple weights can easily exceed 1 MB; subset to the characters and features your project actually uses.

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

Get CLI access →