# .ttf

> The `.ttf` (TrueType Font) is a font file format developed by Apple and Microsoft, widely used for both screen and printer fonts.

## Should I use TTF fonts on a website or convert them to WOFF2?

The font format developed by Apple and Microsoft that provides high-quality text rendering for both screen and print. It's widely supported across various platforms and allows for easy installation and embedding of fonts in documents.

- Topic: Fonts
- Type: format

## Example

Wrong:

```css
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter.ttf');
}
```

Right:

```css
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter.woff2') format('woff2');
  font-display: swap;
}
```

WOFF2 compresses the same TrueType data much smaller, and `font-display: swap` keeps text visible while it loads.

## Common mistakes

- Serving desktop `.ttf` files on the web, which are larger than needed.
- Shipping the full font with every language when the site uses one script.

## Key points

- `@font-face` loads a `.woff2` file, not a raw `.ttf`, for web pages.
- The `format()` hint matches the file: 'woff2' for `.woff2`, 'truetype' for `.ttf`.
- The font license allows web embedding before the file is self-hosted.

## Interview questions

### TTF vs OTF: what is the difference?

TTF uses TrueType outlines, while OTF usually uses CFF outlines and often more features. For screens and the web the difference is small.

### How do I convert TTF to WOFF2?

Use a font tool such as `fonttools` or the `woff2_compress` utility. Subset the font at the same time to cut its size further.

## Related cards

- [.woff2](https://wonderium.dev/engineering/woff2.md)
- [.otf](https://wonderium.dev/engineering/otf.md)
- [@font-face](https://wonderium.dev/css/font-face.md)
- [font-display](https://wonderium.dev/css/font-display.md)

---

- Level: [Engineering](https://wonderium.dev/engineering.md)
- HTML version: https://wonderium.dev/engineering/ttf
- Last updated: 2026-11-25
