feat(font): add the FreeType-only font backend (font-backend-freetype)

Ghostty can be built with -Dfont-backend=freetype, which uses FreeType
without any font discovery. The Rust port only had fontconfig+freetype
(default on Linux) and the CoreText variants. The new cargo feature
`font-backend-freetype` on ghostty-font (forwarded by ghostty-cli and
the root crate; non-Apple, non-wasm targets) behaves like Zig's mode:
font-family discovery, fallback search and codepoint-map overrides are
skipped (embedded fonts only); +list-fonts and +show-face print Zig's
"built without a font discovery mechanism" message and exit 1; +version
reports `.freetype`. The default backend is unchanged.

Also registers the Rust-only benchmark tooling extensions (--time,
--handler=full, ghostty-synthetic +sgr) in DEVIANT_FIXES.md.

Note: `--all-features` now selects this backend for the workspace.

Test Plan:
- cargo test -p ghostty-font --features font-backend-freetype (198)
- cargo build --features font-backend-freetype && ghostty +list-fonts
This commit is contained in:
ddidderr committed 2026-10-12 15:56:21 +02:00
1 parent 798a31ccac
commit 389266720d
18 files changed
+327 -12

No files matched your search

+36
View File
@@ -10,6 +10,42 @@ pub use fc_impl::*;
mod coretext_impl;
#[cfg(font_coretext)]
pub use coretext_impl::*;
/// The `freetype` backend has no discovery mechanism: Zig's
/// `Discover = void`. This is an uninhabited stand-in so that generic code
/// type-checks; it can never be constructed, and the callers check
/// [`crate::HAS_DISCOVERY`] (or `cfg(font_discovery)`) first.
#[cfg(not(any(font_fontconfig, font_coretext)))]
pub struct Discover(std::convert::Infallible);
#[cfg(not(any(font_fontconfig, font_coretext)))]
pub type DiscoverError = std::convert::Infallible;
#[cfg(not(any(font_fontconfig, font_coretext)))]
pub type NextError = std::convert::Infallible;
#[cfg(not(any(font_fontconfig, font_coretext)))]
pub struct DiscoverIterator(std::convert::Infallible);
#[cfg(not(any(font_fontconfig, font_coretext)))]
impl Discover {
#[must_use]
pub fn init() -> Discover {
unreachable!("no font discovery mechanism in this build")
}
pub fn discover(&self, _desc: &Descriptor) -> Result<DiscoverIterator, DiscoverError> {
match self.0 {}
}
}
#[cfg(not(any(font_fontconfig, font_coretext)))]
impl DiscoverIterator {
#[allow(clippy::should_implement_trait)]
pub fn next(&mut self) -> Result<Option<crate::deferred_face::DeferredFace>, NextError> {
match self.0 {}
}
}
/// Descriptor is used to search for fonts (canonical definition in `ghostty-config`).
pub use ghostty_config::font_types::Descriptor;