fix: inspector font/formatting, FreeType-only backend on Apple

Resolves the parity items of docs/rewrite/notes/review-rv17-codex.md
(final-Z20.md):
- FreeType-only font backend is also available on Apple targets
  (discovery-free, embedded emoji fonts); ghostty_surface_quicklook_font
  returns null for every backend except plain CoreText like Zig.
- The +list-fonts test keys off the font crate's selected backend
  (HAS_DISCOVERY), correct under feature unification and on Apple.
- Inspector font: 32 px rasterized with FreeType (dear-imgui freetype)
  like Ghostty; a new `visual-parity.sh inspector` scenario shows 0.031%
  differing pixels (hover highlight) vs the original on Linux. Windows,
  Apple and wasm keep stb_truetype at 32 px (registered as a deliberate
  deviation).
- Inspector DCS/APC descriptions follow Zig 0.15.2's formatting
  (checked by running Zig), incl. the terminal.Parser.Action prefix.
- The ImGui demo window appears only in dev-profile builds, mirroring
  Zig's .Debug-only gate.

Test Plan:
- cargo test --workspace --no-fail-fast (3582 passed)
- just check-macos (both, also with --features font-backend-freetype)
- scripts/visual-parity.sh inspector
This commit is contained in:
ddidderr committed 2026-10-12 16:23:54 +02:00
1 parent 5ab6dba4a4
commit 132f7c27ba
18 files changed
+267 -83

No files matched your search

@@ -97,7 +97,7 @@ mod imp {
let weak = obj.downgrade();
obj.upcast_ref::<ImguiWidget>().set_hooks(
// Called to do initial setup of the UI.
Box::new(ghostty_inspector::setup),
Box::new(|ctx, _scale| ghostty_inspector::setup(ctx)),
// Called for every frame to draw the UI.
Box::new(move |ui| {
let Some(this) = weak.upgrade() else {
+19 -11
View File
@@ -134,20 +134,28 @@ pub fn run(args: &[impl AsRef<[u8]>]) -> Result<u8, Error> {
#[cfg(test)]
mod tests {
/// Keyed off the font crate's actually selected backend, not this
/// crate's own feature flag: cargo feature unification can enable
/// `ghostty-font/font-backend-freetype` without the CLI forwarding
/// feature, and on Apple targets the default backend (CoreText) has
/// discovery.
///
/// Without a discovery mechanism (the `freetype` font backend, Zig
/// `Discover == void`) `+list-fonts` prints the compile-time-option
/// message and exits with 1, after parsing the arguments.
#[cfg(feature = "font-backend-freetype")]
#[test]
fn freetype_backend_reports_no_discovery() {
const { assert!(!ghostty_font::HAS_DISCOVERY) };
assert_eq!(super::run(&[] as &[&[u8]]).expect("run"), 1);
assert!(super::NO_DISCOVERY_MESSAGE.ends_with("try again."));
}
#[cfg(not(feature = "font-backend-freetype"))]
#[test]
fn default_backend_has_discovery() {
const { assert!(ghostty_font::HAS_DISCOVERY) };
fn discovery_presence_follows_selected_backend() {
let backend = ghostty_font::options.backend;
assert_eq!(
ghostty_font::HAS_DISCOVERY,
backend.has_fontconfig() || backend.has_coretext()
);
if ghostty_font::HAS_DISCOVERY {
assert_ne!(backend, ghostty_font::Backend::Freetype);
} else {
assert_eq!(backend, ghostty_font::Backend::Freetype);
assert_eq!(super::run(&[] as &[&[u8]]).expect("run"), 1);
assert!(super::NO_DISCOVERY_MESSAGE.ends_with("try again."));
}
}
}
+5 -6
View File
@@ -745,6 +745,10 @@ impl Surface {
#[cfg(target_vendor = "apple")]
#[must_use]
pub fn quicklook_font(&self, scale: f32) -> Option<*mut std::ffi::c_void> {
// For non-CoreText (and the other CoreText variants) we return none.
if ghostty_font::options.backend != ghostty_font::Backend::Coretext {
return None;
}
let grid = self.renderer.font_grid();
let mut state = grid.write();
let face = state
@@ -752,12 +756,7 @@ impl Surface {
.collection
.get_face(ghostty_font::collection::Index::default())
.ok()?;
let font = face.quicklook_font(f64::from(scale));
Some(
objc2_core_foundation::CFRetained::into_raw(font)
.as_ptr()
.cast(),
)
ghostty_font::face::quicklook_font_raw(face, f64::from(scale))
}
/// Current sizes.
+8 -7
View File
@@ -40,7 +40,7 @@ harfbuzz-sys = { version = "0.8.0", features = ["bundled"] }
# Like upstream (which builds them from source) the bundled copies are used,
# so no system library is needed on macOS.
freetype-sys = { version = "0.23.0", optional = true, features = ["bundled"] }
harfbuzz-sys = { version = "0.8.0", optional = true, default-features = false, features = ["coretext", "bundled"] }
harfbuzz-sys = { version = "0.8.0", optional = true, default-features = false, features = ["bundled"] }
objc2 = "0.6.5"
objc2-core-foundation = "0.3.2"
objc2-core-graphics = "0.3.2"
@@ -51,18 +51,19 @@ objc2-foundation = "0.3.2"
default = []
# CoreText for discovery, FreeType for rendering, HarfBuzz for shaping
# (Zig `-Dfont-backend=coretext_freetype`; Apple targets only).
coretext-freetype = ["dep:freetype-sys", "dep:harfbuzz-sys", "harfbuzz-sys/freetype"]
coretext-freetype = ["dep:freetype-sys", "dep:harfbuzz-sys", "harfbuzz-sys/freetype", "harfbuzz-sys/coretext"]
# CoreText for discovery and rendering, HarfBuzz for shaping
# (Zig `-Dfont-backend=coretext_harfbuzz`; Apple targets only).
coretext-harfbuzz = ["dep:harfbuzz-sys"]
coretext-harfbuzz = ["dep:harfbuzz-sys", "harfbuzz-sys/coretext"]
# CoreText for discovery and rendering, no shaping
# (Zig `-Dfont-backend=coretext_noshape`; Apple targets only).
coretext-noshape = []
# FreeType for rendering and HarfBuzz for shaping with no font discovery
# (Zig `-Dfont-backend=freetype`; non-Apple, non-wasm targets only; the
# default there is `fontconfig_freetype`). Not enabled by `--all-features`
# in any meaningful sense: it switches the whole build to the backend.
font-backend-freetype = []
# (Zig `-Dfont-backend=freetype`; every target but wasm32, Apple included;
# the default on Linux is `fontconfig_freetype`). Not enabled by
# `--all-features` in any meaningful sense: it switches the whole build to
# the backend.
font-backend-freetype = ["dep:freetype-sys", "dep:harfbuzz-sys", "harfbuzz-sys/freetype"]
# This crate wraps the freetype / harfbuzz / fontconfig C libraries through
# their `-sys` crates; unsafe is denied by default and allowed on minimal,
+17 -15
View File
@@ -3,9 +3,10 @@
//!
//! Backends (see `src/backend.rs`):
//! * Linux & other non-Apple, non-wasm targets: `fontconfig_freetype`.
//! * Linux & other non-Apple, non-wasm targets with the cargo feature
//! * Any non-wasm target (Apple included) with the cargo feature
//! `font-backend-freetype`: `freetype` (FreeType rendering, HarfBuzz
//! shaping, no font discovery; Zig `-Dfont-backend=freetype`).
//! shaping, no font discovery; Zig `-Dfont-backend=freetype`). On Apple
//! it takes precedence over the `coretext-*` features.
//! * wasm32: `web_canvas`.
//! * Apple targets: `coretext` (default), or via cargo features
//! `coretext-freetype`, `coretext-harfbuzz`, `coretext-noshape`.
@@ -46,14 +47,15 @@ fn main() {
let ct_hb = feat("CORETEXT_HARFBUZZ");
let ct_noshape = feat("CORETEXT_NOSHAPE");
// Zig `-Dfont-backend=freetype` is valid on every non-wasm target,
// Darwin included (no discovery, so the embedded emoji fonts are used).
let ft_only = feat("FONT_BACKEND_FREETYPE");
if ft_only && (wasm || apple) {
println!(
"cargo:warning=feature `font-backend-freetype` only applies to non-Apple, \
non-wasm targets; ignored"
);
if ft_only && wasm {
println!("cargo:warning=feature `font-backend-freetype` does not apply to wasm32; ignored");
}
let ft_only = ft_only && !wasm && !apple;
let ft_only = ft_only && !wasm;
// CoreText is the backend on Apple targets unless FreeType-only is asked.
let coretext = apple && !ft_only;
let on = |c: &str, v: bool| {
if v {
@@ -61,17 +63,17 @@ fn main() {
}
};
let freetype = !wasm && (!apple || ct_ft);
let harfbuzz = !wasm && (!apple || ct_ft || ct_hb);
let freetype = !wasm && (!coretext || ct_ft);
let harfbuzz = !wasm && (!coretext || ct_ft || ct_hb);
on("font_freetype", freetype);
let fontconfig = !wasm && !apple && !ft_only;
on("font_fontconfig", fontconfig);
on("font_discovery", fontconfig || apple);
on("font_discovery", fontconfig || coretext);
on("font_harfbuzz", harfbuzz);
on("font_coretext", apple);
on("font_coretext_face", apple && !ct_ft);
on("font_coretext", coretext);
on("font_coretext_face", coretext && !ct_ft);
// The shaper is CoreText only for the plain `coretext` backend;
// `coretext_noshape` uses the no-op shaper.
on("font_coretext_shaper", apple && !harfbuzz && !ct_noshape);
on("font_noshape", apple && !harfbuzz && ct_noshape);
on("font_coretext_shaper", coretext && !harfbuzz && !ct_noshape);
on("font_noshape", coretext && !harfbuzz && ct_noshape);
}
+26 -13
View File
@@ -13,9 +13,10 @@
//! (Zig: `-Dfont-backend=...`). "There is no scenario that is the default"
//! for those; they're only used by people who want to self-compile Ghostty
//! and prefer the freetype aesthetic.
//! * Non-Apple, non-wasm targets with the cargo feature
//! * Non-wasm targets (Apple included) with the cargo feature
//! `font-backend-freetype`: [`Backend::Freetype`] (Zig
//! `-Dfont-backend=freetype`: no font discovery).
//! `-Dfont-backend=freetype`: no font discovery; takes precedence over the
//! `coretext-*` features).
//! * wasm32: [`Backend::WebCanvas`].
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -104,11 +105,7 @@ pub struct Options {
pub backend: Backend,
}
#[cfg(all(
not(target_arch = "wasm32"),
not(target_vendor = "apple"),
feature = "font-backend-freetype"
))]
#[cfg(all(not(target_arch = "wasm32"), feature = "font-backend-freetype"))]
pub const OPTIONS: Options = Options {
backend: Backend::Freetype,
};
@@ -122,13 +119,18 @@ pub const OPTIONS: Options = Options {
backend: Backend::FontconfigFreetype,
};
#[cfg(all(target_vendor = "apple", feature = "coretext-freetype"))]
#[cfg(all(
target_vendor = "apple",
feature = "coretext-freetype",
not(feature = "font-backend-freetype")
))]
pub const OPTIONS: Options = Options {
backend: Backend::CoretextFreetype,
};
#[cfg(all(
target_vendor = "apple",
not(feature = "font-backend-freetype"),
feature = "coretext-harfbuzz",
not(feature = "coretext-freetype")
))]
@@ -138,6 +140,7 @@ pub const OPTIONS: Options = Options {
#[cfg(all(
target_vendor = "apple",
not(feature = "font-backend-freetype"),
feature = "coretext-noshape",
not(feature = "coretext-freetype"),
not(feature = "coretext-harfbuzz")
@@ -148,6 +151,7 @@ pub const OPTIONS: Options = Options {
#[cfg(all(
target_vendor = "apple",
not(feature = "font-backend-freetype"),
not(feature = "coretext-freetype"),
not(feature = "coretext-harfbuzz"),
not(feature = "coretext-noshape")
@@ -165,6 +169,19 @@ pub const OPTIONS: Options = Options {
mod tests {
use super::*;
/// The `build.rs` cfgs must agree with the selected backend on every
/// target, including FreeType-only on Apple (Zig `Backend.has*`).
#[test]
fn selected_backend_matches_build_cfgs() {
let b = OPTIONS.backend;
assert_eq!(b.has_freetype(), cfg!(font_freetype));
assert_eq!(b.has_fontconfig(), cfg!(font_fontconfig));
assert_eq!(b.has_coretext(), cfg!(font_coretext));
assert_eq!(b.has_harfbuzz(), cfg!(font_harfbuzz));
assert_eq!(cfg!(font_discovery), b.has_fontconfig() || b.has_coretext());
assert_eq!(crate::HAS_DISCOVERY, cfg!(font_discovery));
}
#[test]
fn web_canvas_capabilities() {
let b = Backend::WebCanvas;
@@ -236,11 +253,7 @@ mod tests {
assert!(!b.has_coretext());
}
#[cfg(all(
not(target_arch = "wasm32"),
not(target_vendor = "apple"),
feature = "font-backend-freetype"
))]
#[cfg(all(not(target_arch = "wasm32"), feature = "font-backend-freetype"))]
#[test]
fn freetype_only_backend_selected() {
let b = OPTIONS.backend;
+19
View File
@@ -31,6 +31,25 @@ pub use ghostty_config::types_b::FreetypeLoadFlags;
#[cfg(target_arch = "wasm32")]
pub use web_canvas::Face;
/// A retained `CTFontRef` of `face` for macOS quicklook (Zig
/// `ghostty_surface_quicklook_font`, which only answers for the plain
/// `.coretext` backend and returns null for every other one, FreeType-only
/// included). The caller owns the reference.
#[cfg(target_vendor = "apple")]
#[must_use]
pub fn quicklook_font_raw(face: &Face, scale: f64) -> Option<*mut std::ffi::c_void> {
#[cfg(font_coretext_face)]
if crate::backend::OPTIONS.backend == crate::Backend::Coretext {
return Some(
objc2_core_foundation::CFRetained::into_raw(face.quicklook_font(scale))
.as_ptr()
.cast(),
);
}
let _ = (face, scale);
None
}
/// If a DPI can't be calculated, this DPI is used. This is probably
/// wrong on modern devices so it is highly recommended you get the DPI
/// using whatever platform method you can.
+7
View File
@@ -13,6 +13,13 @@ ghostty-terminal.workspace = true
ghostty-vt.workspace = true
log = "0.4"
# Zig builds Dear ImGui with `-DIMGUI_ENABLE_FREETYPE` (pkg/dcimgui), so the
# inspector font is rasterized with FreeType. The `freetype` feature needs a
# system FreeType (pkg-config); other targets keep stb_truetype (see
# `docs/rewrite/DEVIANT_FIXES.md`).
[target.'cfg(not(any(windows, target_vendor = "apple", target_arch = "wasm32")))'.dependencies]
dear-imgui-rs = { version = "0.19", features = ["freetype"] }
[lints.rust]
unsafe_code = "deny"
+14
View File
@@ -0,0 +1,14 @@
//! Emits `cfg(ghostty_debug_build)` for the Cargo `dev` profile (Zig
//! `builtin.mode == .Debug`). `debug_assertions` is not equivalent: the
//! repository's `release` profile enables it, like Zig's `ReleaseSafe`.
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=PROFILE");
println!("cargo:rustc-check-cfg=cfg(ghostty_debug_build)");
let profile = std::env::var("PROFILE").unwrap_or_default();
println!("cargo:rustc-env=GHOSTTY_BUILD_PROFILE={profile}");
if profile == "debug" {
println!("cargo:rustc-cfg=ghostty_debug_build");
}
}
+41 -14
View File
@@ -2,18 +2,19 @@
use std::sync::{Mutex, MutexGuard, PoisonError};
use dear_imgui_rs::{ConfigFlags, Context, FontSource, StbTrueTypeFontData, Ui};
use dear_imgui_rs::{ConfigFlags, Context, FontSource, Ui};
use ghostty_renderer::{overlay::Feature, state::InspectorHook};
use ghostty_terminal::terminal::Terminal;
use crate::widgets;
/// The inspector font size in pixels. Zig hardcodes `16 * 2` ("This is
/// currently hardcoded to a 2x content scale", with a TODO to recalculate it
/// for different screen DPIs); the style is scaled separately by the apprt.
pub const FONT_SIZE: f32 = 16.0 * 2.0;
/// Setup the ImGui state. This requires an ImGui context.
///
/// `scale_factor` is the content scale of the display; Zig hardcodes a 2x
/// scale here (with a TODO) and sizes the font as `16 * 2`, this uses
/// `16 * scale_factor` instead.
pub fn setup(ctx: &mut Context, scale_factor: f64) {
pub fn setup(ctx: &mut Context) {
let io = ctx.io_mut();
// Enable docking, which we use heavily for the UI. Our colorspace is
@@ -28,14 +29,28 @@ pub fn setup(ctx: &mut Context, scale_factor: f64) {
log::warn!("failed to disable the imgui log file err={err}");
}
// Use our own embedded font
let font_size = (16.0 * scale_factor.max(1.0)) as f32;
match StbTrueTypeFontData::from_slice(ghostty_font::embedded::REGULAR) {
Ok(data) => {
ctx.font_atlas()
.add_font(&[FontSource::stb_truetype_with_size(data, font_size)]);
// Use our own embedded font. The atlas rasterizes it with FreeType (the
// default loader of the `freetype` build of Dear ImGui, as in Zig) where
// that build is available, otherwise with stb_truetype.
ctx.font_atlas().add_font(&[embedded_font_source()]);
}
#[cfg(not(any(windows, target_vendor = "apple", target_arch = "wasm32")))]
#[allow(unsafe_code)]
fn embedded_font_source() -> FontSource<'static> {
// SAFETY: the embedded font is a complete, valid TrueType font that
// lives for the whole program; Dear ImGui copies it on add.
unsafe { FontSource::ttf_data_with_size(ghostty_font::embedded::REGULAR, FONT_SIZE) }
}
#[cfg(any(windows, target_vendor = "apple", target_arch = "wasm32"))]
fn embedded_font_source() -> FontSource<'static> {
match dear_imgui_rs::StbTrueTypeFontData::from_slice(ghostty_font::embedded::REGULAR) {
Ok(data) => FontSource::stb_truetype_with_size(data, FONT_SIZE),
Err(err) => {
log::warn!("failed to load the embedded inspector font err={err}");
FontSource::default_font_with_size(FONT_SIZE)
}
Err(err) => log::warn!("failed to load the embedded inspector font err={err}"),
}
}
@@ -110,6 +125,18 @@ impl InspectorHook for Shared {
#[cfg(test)]
mod tests {
/// Zig sizes the font as `16 * 2` and rasterizes with FreeType.
#[test]
fn font_size_and_rasterizer_match_zig() {
assert!((super::FONT_SIZE - 32.0).abs() < f32::EPSILON);
let freetype_target = cfg!(not(any(
windows,
target_vendor = "apple",
target_arch = "wasm32"
)));
assert_eq!(dear_imgui_rs::HAS_FREETYPE, freetype_target);
}
use ghostty_input::{Action, Key, KeyEvent};
use ghostty_renderer::size::{CellSize, Padding, ScreenSize, Size};
use ghostty_terminal::terminal::Options;
@@ -146,7 +173,7 @@ mod tests {
#[test]
fn draws_frames_headless() {
let mut ctx = Context::create();
setup(&mut ctx, 1.0);
setup(&mut ctx);
ctx.io_mut().set_display_size([1000.0, 700.0]);
ctx.io_mut().set_delta_time(1.0 / 60.0);
ctx.font_atlas()
@@ -13,6 +13,10 @@ use super::{key, renderer, terminal, termio};
use crate::dock::begin_window;
/// This is discovered via the hardcoded string in the ImGui demo window.
/// True for the Cargo `dev` profile only (Zig `builtin.mode == .Debug`);
/// set by `build.rs` from `PROFILE`, deliberately not `debug_assertions`.
pub const DEBUG_BUILD: bool = cfg!(ghostty_debug_build);
const WINDOW_IMGUI_DEMO: &str = "Dear ImGui Demo";
const WINDOW_KEYBOARD: &str = "Keyboard";
const WINDOW_TERMINAL: &str = "Terminal";
@@ -133,8 +137,10 @@ impl Inspector {
crate::dock::flush_splits(ui);
// In debug we show the ImGui demo window so we can easily view
// available widgets and such.
if cfg!(debug_assertions) && self.show_demo_window {
// available widgets and such. Zig checks `builtin.mode == .Debug`
// (not `ReleaseSafe`), which is the Cargo `dev` profile; assertions
// enabled in a release profile do not count.
if DEBUG_BUILD && self.show_demo_window {
ui.show_demo_window(&mut self.show_demo_window);
}
@@ -399,6 +405,14 @@ fn mouse_button_label(button: usize) -> &'static str {
mod tests {
use super::*;
#[test]
fn demo_window_gate_follows_the_dev_profile() {
// The `release` profile keeps debug assertions on (like Zig's
// ReleaseSafe) but must not show the demo.
let debug_build = DEBUG_BUILD;
assert_eq!(debug_build, env!("GHOSTTY_BUILD_PROFILE") == "debug");
}
#[test]
fn button_labels() {
assert_eq!(mouse_button_label(0), "?");
+53 -6
View File
@@ -259,16 +259,20 @@ fn encode_action(md: &mut Vec<(String, String)>, action: &ParserAction) -> Strin
}
}
/// Mirrors `Parser.Action.format` for the actions that are not specially
/// encoded.
/// Mirrors Zig 0.15.2 `Parser.Action.format` for the actions that are not
/// specially encoded: `@typeName(Action)`, then `{ .<tag> = <value> }` with
/// `u8` payloads as `0x{x}` and every other payload printed with
/// `printValue("any", .., depth 3)`: structs as `.{ .a = .., .b = .. }`,
/// slices as `{ a, b }` (`{ }` when empty), integers in decimal and `void`
/// as `void`.
fn format_action(action: &ParserAction) -> String {
let (tag, value) = match action {
ParserAction::DcsHook(d) => (
"dcs_hook",
format!(
"{{ intermediates = {:?}, params = {:?}, final = {} }}",
d.intermediates(),
d.params(),
".{{ .intermediates = {}, .params = {}, .final = {} }}",
zig_any_slice(d.intermediates()),
zig_any_slice(d.params()),
d.final_
),
),
@@ -280,7 +284,21 @@ fn format_action(action: &ParserAction) -> String {
// Handled by the specific encoders.
_ => ("unknown", String::new()),
};
format!("parser.Parser.Action{{ .{tag} = {value} }}")
format!("terminal.Parser.Action{{ .{tag} = {value} }}")
}
/// A slice of integers as Zig's `{any}` prints it: `{ 1, 2 }`, or `{ }`
/// when empty.
fn zig_any_slice<T: std::fmt::Display>(items: &[T]) -> String {
let mut out = String::from("{ ");
for (i, v) in items.iter().enumerate() {
if i != 0 {
out.push_str(", ");
}
let _ = write!(out, "{v}");
}
out.push_str(" }");
out
}
fn encode_print(ch: u32) -> String {
@@ -927,6 +945,35 @@ mod tests {
assert!(filter("-").pass_filter("abc"));
}
#[test]
fn dcs_and_apc_descriptions_match_zig_format() {
// Expected strings produced by Zig 0.15.2 `Parser.Action.format`.
let hook = ParserAction::DcsHook(ghostty_vt::parser::Dcs::new(b"$ ", &[1, 2, 300], b'q'));
assert_eq!(
format_action(&hook),
"terminal.Parser.Action{ .dcs_hook = .{ .intermediates = { 36, 32 }, \
.params = { 1, 2, 300 }, .final = 113 } }"
);
let empty = ParserAction::DcsHook(ghostty_vt::parser::Dcs::new(b"", &[], b'q'));
assert_eq!(
format_action(&empty),
"terminal.Parser.Action{ .dcs_hook = .{ .intermediates = { }, \
.params = { }, .final = 113 } }"
);
assert_eq!(
format_action(&ParserAction::DcsUnhook),
"terminal.Parser.Action{ .dcs_unhook = void }"
);
assert_eq!(
format_action(&ParserAction::DcsPut(0x1b)),
"terminal.Parser.Action{ .dcs_put = 0x1b }"
);
assert_eq!(
format_action(&ParserAction::ApcPut(0x41)),
"terminal.Parser.Action{ .apc_put = 0x41 }"
);
}
#[test]
fn encode_execute_names() {
assert_eq!(encode_execute(0x07), "BEL (0x7)");
+1 -2
View File
@@ -54,8 +54,7 @@ impl Inspector {
}
// Setup our core inspector
let scale = f64::from(RtSurface::get_content_scale(surface.as_ref()).x);
ghostty_inspector::setup(&mut ctx, scale);
ghostty_inspector::setup(&mut ctx);
if let Err(err) = core.activate_inspector() {
log::error!("failed to activate inspector err={err}");
}