diff --git a/config/src/lib.rs b/config/src/lib.rs index 04395c7e1..e95a52e9f 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -1253,8 +1253,8 @@ fn default_font_size() -> f64 { 10.0 } -fn default_dpi() -> f64 { - 96.0 +pub fn default_dpi() -> f64 { + ::window::DEFAULT_DPI } fn compute_runtime_dir() -> Result { diff --git a/docs/changelog.markdown b/docs/changelog.markdown index cdf4d3d5a..6f774d111 100644 --- a/docs/changelog.markdown +++ b/docs/changelog.markdown @@ -23,6 +23,7 @@ brief notes about them may accumulate here. * Fixed ALT-Escape not sending ESC-ESC [#338](https://github.com/wez/wezterm/issues/338) * Added `allow_square_glyphs_to_overflow_width = "WhenFollowedBySpace"` option to allow square symbol glyphs to deliberately overflow their specified cell width when the next cell is a space. Can be set to `Always` to allow overflowing regardless of the next cell being a space, or `Never` to strictly respect the cell width. The default is `Never`. [#342](https://github.com/wez/wezterm/issues/342) * macOS: Improved key input when Option is pressed. Fixed dead key processing when `use_ime=true`. [#357](https://github.com/wez/wezterm/issues/357) +* macOS: Adjusted default dpi to 72 to bring point sizes into alignment with other macOS apps. [#332](https://github.com/wez/wezterm/issues/332) ### 20201101-103216-403d002d diff --git a/wezterm-gui/src/gui/termwindow.rs b/wezterm-gui/src/gui/termwindow.rs index 7ffc467e9..e9476dd1b 100644 --- a/wezterm-gui/src/gui/termwindow.rs +++ b/wezterm-gui/src/gui/termwindow.rs @@ -27,7 +27,7 @@ use anyhow::{anyhow, bail, ensure}; use config::keyassignment::{ InputMap, KeyAssignment, MouseEventTrigger, SpawnCommand, SpawnTabDomain, }; -use config::{configuration, ConfigHandle}; +use config::{configuration, default_dpi, ConfigHandle}; use lru::LruCache; use mux::activity::Activity; use mux::domain::{DomainId, DomainState}; @@ -2113,7 +2113,7 @@ impl TermWindow { fn apply_scale_change(&mut self, dimensions: &Dimensions, font_scale: f64) { self.fonts - .change_scaling(font_scale, dimensions.dpi as f64 / 96.); + .change_scaling(font_scale, dimensions.dpi as f64 / default_dpi()); self.render_metrics = RenderMetrics::new(&self.fonts); if self.render_state.has_opengl() { self.render_state.opengl().glyph_cache.borrow_mut().clear(); diff --git a/window/src/lib.rs b/window/src/lib.rs index ca2083e0f..4f3037978 100644 --- a/window/src/lib.rs +++ b/window/src/lib.rs @@ -9,6 +9,11 @@ pub mod os; mod spawn; mod timerlist; +#[cfg(target_os = "macos")] +pub const DEFAULT_DPI: f64 = 72.0; +#[cfg(not(target_os = "macos"))] +pub const DEFAULT_DPI: f64 = 96.0; + #[cfg(feature = "opengl")] mod egl; diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index 6de083ce8..34dc5bec8 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -484,7 +484,7 @@ impl Window { inner.borrow_mut().callbacks.resize(Dimensions { pixel_width: width as usize, pixel_height: height as usize, - dpi: (96.0 * (backing_frame.size.width / frame.size.width)) as usize, + dpi: (crate::DEFAULT_DPI * (backing_frame.size.width / frame.size.width)) as usize, }); Ok(window) @@ -1395,7 +1395,7 @@ impl WindowView { this.inner.borrow_mut().callbacks.resize(Dimensions { pixel_width: width as usize, pixel_height: height as usize, - dpi: (96.0 * (backing_frame.size.width / frame.size.width)) as usize, + dpi: (crate::DEFAULT_DPI * (backing_frame.size.width / frame.size.width)) as usize, }); } } @@ -1460,7 +1460,7 @@ impl WindowView { let mut ctx = MacGraphicsContext { buffer: &mut *buffer, - dpi: (96.0 * backing_frame.size.width / frame.size.width) as usize, + dpi: (crate::DEFAULT_DPI * backing_frame.size.width / frame.size.width) as usize, }; inner.callbacks.paint(&mut ctx); diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rs index 68f737c4a..35c89f222 100644 --- a/window/src/os/wayland/window.rs +++ b/window/src/os/wayland/window.rs @@ -190,7 +190,7 @@ impl WaylandWindow { let dimensions = Dimensions { pixel_width: width, pixel_height: height, - dpi: 96, + dpi: crate::DEFAULT_DPI as usize, }; let mut window = conn @@ -422,7 +422,7 @@ impl WaylandWindowInner { } fn get_dpi_factor(&self) -> i32 { - self.dimensions.dpi as i32 / 96 + self.dimensions.dpi as i32 / crate::DEFAULT_DPI as i32 } fn get_dpi(&self) -> usize { @@ -481,7 +481,7 @@ impl WaylandWindowInner { let new_dimensions = Dimensions { pixel_width: pixel_width.try_into().unwrap(), pixel_height: pixel_height.try_into().unwrap(), - dpi: factor as usize * 96, + dpi: factor as usize * crate::DEFAULT_DPI as usize, }; // Only trigger a resize if the new dimensions are different; // this makes things more efficient and a little more smooth diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rs index d890fe08b..c77555878 100644 --- a/window/src/os/x11/window.rs +++ b/window/src/os/x11/window.rs @@ -90,7 +90,7 @@ impl<'a> PaintContext for X11GraphicsContext<'a> { Dimensions { pixel_width, pixel_height, - dpi: 96, + dpi: crate::DEFAULT_DPI as usize, } } @@ -346,7 +346,7 @@ impl XWindowInner { self.callbacks.resize(Dimensions { pixel_width: self.width as usize, pixel_height: self.height as usize, - dpi: 96, + dpi: crate::DEFAULT_DPI as usize, }) } xcb::KEY_PRESS | xcb::KEY_RELEASE => {