Files
ghostty-rs/crates/ghostty-font/src/embedded.rs
T
ddidderr 25801765eb feat(font): port the Linux font engine
Ports the rest of ZIG/src/font for the freetype/fontconfig/harfbuzz
backend: face loading and rasterization (synthetic bold/italic, color
emoji bitmaps, glyph constraints for nerd font icons), fontconfig
discovery, DeferredFace, Collection, CodepointResolver, CodepointMap,
SharedGrid, opentype table parsers, the nerd font attribute table, and
the harfbuzz shaper with feature parsing and shaping cache.

Embedded fonts (JetBrains Mono 2.304 variable, Symbols Nerd Font 3.4.0,
Noto emoji) and the test fonts from Ghostty live in res/ with their OFL/
MIT licenses.

The crate opts into unsafe_code = "deny"; FFI is confined to ft.rs,
fontconfig.rs and hb.rs with SAFETY comments. Glyph resampling uses an
stb-style resampler that is not bit-identical to stb.

Deferred to the next font pass (needs ghostty-terminal/config):
shaper/run.zig, SharedGridSet.zig and the 23 terminal-driven shaper
tests. Config-facing types are mirrored locally in config_types.rs.

Test Plan:
- cargo test -p ghostty-font (139 tests)
2026-10-11 22:13:06 +02:00

56 lines
2.8 KiB
Rust

//! Fonts that can be embedded with Ghostty. Note they are only actually
//! embedded in the binary if they are referenced by the code, so fonts
//! used for tests will not result in the final binary being larger.
//!
//! Be careful to ensure that any fonts you embed are licensed for
//! redistribution and include their license as necessary (see `res/`).
/// Default fonts that we prefer for Ghostty.
pub static VARIABLE: &[u8] = include_bytes!("../res/JetBrainsMono-Variable.ttf");
pub static VARIABLE_ITALIC: &[u8] = include_bytes!("../res/JetBrainsMono-Italic-Variable.ttf");
/// Symbols-only nerd font.
pub static SYMBOLS_NERD_FONT: &[u8] = include_bytes!("../res/SymbolsNerdFont-Regular.ttf");
/// Static jetbrains mono faces, currently unused (except by tests).
pub static REGULAR: &[u8] = include_bytes!("../res/JetBrainsMono-Regular.ttf");
pub static BOLD: &[u8] = include_bytes!("../res/JetBrainsMono-Bold.ttf");
pub static ITALIC: &[u8] = include_bytes!("../res/JetBrainsMono-Italic.ttf");
pub static BOLD_ITALIC: &[u8] = include_bytes!("../res/JetBrainsMono-BoldItalic.ttf");
/// Emoji fonts
pub static EMOJI: &[u8] = include_bytes!("../res/NotoColorEmoji.ttf");
pub static EMOJI_TEXT: &[u8] = include_bytes!("../res/NotoEmoji-Regular.ttf");
// Fonts below are ONLY used for testing.
/// Fonts with general properties
pub static ARABIC: &[u8] = include_bytes!("../res/KawkabMono-Regular.ttf");
/// A font for testing which is patched with nerd font symbols.
pub static TEST_NERD_FONT: &[u8] = include_bytes!("../res/JetBrainsMonoNerdFont-Regular.ttf");
/// Specific font families below:
pub static CODE_NEW_ROMAN: &[u8] = include_bytes!("../res/CodeNewRoman-Regular.otf");
pub static INCONSOLATA: &[u8] = include_bytes!("../res/Inconsolata-Regular.ttf");
pub static GEIST_MONO: &[u8] = include_bytes!("../res/GeistMono-Regular.ttf");
pub static JETBRAINS_MONO: &[u8] = include_bytes!("../res/JetBrainsMonoNoNF-Regular.ttf");
pub static JULIA_MONO: &[u8] = include_bytes!("../res/JuliaMono-Regular.ttf");
/// Cozette is a unique font because it embeds some emoji characters
/// but has a text presentation.
pub static COZETTE: &[u8] = include_bytes!("../res/CozetteVector.ttf");
/// Monaspace has weird ligature behaviors we want to test in our shapers
/// so we embed it here.
pub static MONASPACE_NEON: &[u8] = include_bytes!("../res/MonaspaceNeon-Regular.otf");
/// Terminus TTF is a scalable font with bitmap glyphs at various sizes.
pub static TERMINUS_TTF: &[u8] = include_bytes!("../res/TerminusTTF-Regular.ttf");
/// Spleen is a monospaced bitmap font available in multiple formats.
/// Used for testing bitmap font support across different file formats.
pub static SPLEEN_BDF: &[u8] = include_bytes!("../res/spleen-8x16.bdf");
pub static SPLEEN_PCF: &[u8] = include_bytes!("../res/spleen-8x16.pcf");
pub static SPLEEN_OTB: &[u8] = include_bytes!("../res/spleen-8x16.otb");