Skip to main content

wezterm.font()

Constructs a font configuration for a single named font with optional style attributes.

Signature

Parameters

string
required
The font family name. Can be one of:
  • Family name (recommended): "JetBrains Mono" - doesn’t include style info
  • Full name: "JetBrains Mono Regular" - includes sub-family
  • PostScript name: Unique identifier encoded by font designer
FontAttributes
Optional table specifying font style attributes:
string
default:"Regular"
Font weight. Options:
  • "Thin"
  • "ExtraLight"
  • "Light"
  • "DemiLight"
  • "Book"
  • "Regular" (default)
  • "Medium"
  • "DemiBold"
  • "Bold"
  • "ExtraBold"
  • "Black"
  • "ExtraBlack"
string
default:"Normal"
Font stretch. Options:
  • "UltraCondensed"
  • "ExtraCondensed"
  • "Condensed"
  • "SemiCondensed"
  • "Normal" (default)
  • "SemiExpanded"
  • "Expanded"
  • "ExtraExpanded"
  • "UltraExpanded"
string
default:"Normal"
Font style. Options:
  • "Normal" (default)
  • "Italic" - distinctive design at an angle
  • "Oblique" - similar to Normal but skewed
string[]
HarfBuzz font shaping features to enable/disable. Example: { 'calt=0', 'clig=0', 'liga=0' } to disable ligatures
string
FreeType load target hint setting
string
FreeType render target setting
string
FreeType load flags
boolean
Control whether font is considered to have emoji presentation glyphs

Return Value

object
A text style object containing font configuration that can be assigned to config.font

Basic Examples

Advanced Features

Disable Ligatures

You can disable ligatures for specific fonts:

Emoji Presentation

Control whether a font is considered to have emoji glyphs:

wezterm.font_with_fallback()

Constructs a font configuration with fallback fonts. Glyphs are looked up in the first font, but if missing, the next font is checked, and so on.

Signature

Parameters

array
required
Array of font families in preferred order. Each element can be:
  • A string font family name
  • A table with family and per-font attributes
FontAttributes
Optional attributes applied to all fonts (unless overridden per-font)

Return Value

object
A text style object with multiple fonts configured in fallback order

Examples

Fallback Font Scaling

When mixing different font families, glyphs may appear to have different heights. WezTerm provides two ways to handle this:

Automatic Scaling

Use the use_cap_height_to_scale_fallback_fonts config option:
This uses the font’s cap-height metric (or computes it) to automatically scale fallback fonts.

Manual Scaling

For CJK fonts or when automatic scaling doesn’t work well, manually specify the scale factor:
Manual scaling cannot influence font metrics, so you may also need to adjust line_height for better appearance.

Font Resolution

WezTerm follows CSS Fonts Level 3 compatible font matching when resolving fonts:
  1. Exact match: Tries to find a font that exactly matches the specified attributes
  2. Close match: If no exact match, finds a close match within the font family
  3. Fallback: If a glyph is missing, tries the next font in the fallback list
WezTerm can only use fonts installed on your system. If you request a condensed variant, you must have the condensed font file installed. WezTerm can synthesize basic bold and oblique for non-bitmap fonts, but this is not recommended.

Important Notes

  • Use family names: The family name (without style info) is the most compatible
  • Install all variants: If you want condensed, bold, or italic fonts, install those font files
  • Implicit fallbacks: WezTerm adds its own default fallback fonts to your list
  • Font files required: All fonts must be installed on your system
  • font_size - Set the font point size
  • font_dirs - Additional directories to search for fonts
  • line_height - Adjust line height multiplier
  • use_cap_height_to_scale_fallback_fonts - Automatic fallback scaling

Source Reference

Implementation: config/src/lua.rs:552-641