wezterm: default dpi on macOS is now 72

https://wiki.lazarus.freepascal.org/Cocoa_DPI states that the dpi
on macOS is 72.  That matches up to the experimental results reported
in #332 (in which 74.0 appears about the right size).

This commit introduces a `DEFAULT_DPI` constant that is set to 72 on
macOS and 96 on other operating systems.

The result of this is that a 10 point Menlo font now appears to be
the same size in Terminal.app and WezTerm.app.

refs: https://github.com/wez/wezterm/issues/332
This commit is contained in:
Wez Furlong committed 2020-12-06 18:34:06 -08:00
1 parent b2be2963a1
commit 92827a1bea
7 files changed
+18 -12

No files matched your search

+2 -2
View File
@@ -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<PathBuf, Error> {
+1
View File
@@ -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
+2 -2
View File
@@ -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();
+5
View File
@@ -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;
+3 -3
View File
@@ -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);
+3 -3
View File
@@ -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
+2 -2
View File
@@ -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 => {