.ttf

Term side of the Card.
Topic: Fonts
Unit title: .ttf
Categories: Format
Explanation side of the Card

Explanation: 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.

Example

Wrongcss
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter.ttf');
}
Rightcss
@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.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy