ZUI

Search documentation

Find a page or a heading.

Font preview

A specimen of a font file at several sizes, one row per size, loaded under a family of its own.

Installation

bash

The CLI writes components/data-display/font-preview.tsx, installs Text and Utils, and adds expo-font.

Usage

tsx
tsx

The consumer places, pads and widths its wrapper; it renders one row per size, largest first, each specimen on one line that ends in an ellipsis at that width. Use it to compare a font file's weights before shipping it; for a previewed image rather than type, use Image preview.

API reference

FontPreview

Takes every prop of React Native's View, plus:

It loads src with expo-font under a family of its own, so several previews on one screen never collide. Until the file has loaded, and if it fails to, the specimens are drawn in the theme's font. iOS and Android load TrueType and OpenType files; a WOFF or WOFF2 file loads on the web only.

Differences from the web

  • format is not taken: expo-font reads a file's format itself, and a device loads no @font-face.
  • The web's data-slot attribute is not set; a View takes no data attributes.