diff --git a/CHANGELOG.md b/CHANGELOG.md index 55692672..e060dd74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Default `bell.animation` is now `Linear` - `IncreaseFontSize/DecreaseFontSize` step is now 1px - `font.size` precision was raised to 6 floating point digits +- Default font size to `11.25` matching 15px ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 5157ae6c..770d86d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,7 +43,7 @@ dependencies = [ "clap_complete", "cocoa", "copypasta", - "crossfont 0.6.0", + "crossfont 0.7.0", "dirs", "embed-resource", "gl_generator", @@ -586,9 +586,9 @@ dependencies = [ [[package]] name = "crossfont" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80c5cf9f7d8f5478dbebc0e7a9ddcd350401e4cd9275d003481d8ec9613b7de1" +checksum = "e89c65306ecd118368d875f48d69394b5c3ff6bb7c57ae6deb638782735a093c" dependencies = [ "cocoa", "core-foundation", diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml index 535a933a..3990dc03 100644 --- a/alacritty/Cargo.toml +++ b/alacritty/Cargo.toml @@ -26,7 +26,7 @@ ahash = { version = "0.8.6", features = ["no-rng"] } bitflags = "2.2.1" clap = { version = "4.2.7", features = ["derive", "env"] } copypasta = { version = "0.10.0", default-features = false } -crossfont = { version = "0.6.0", features = ["force_system_fontconfig"] } +crossfont = { version = "0.7.0", features = ["force_system_fontconfig"] } glutin = { version = "0.31.1", default-features = false, features = ["egl", "wgl"] } home = "0.5.5" libc = "0.2" diff --git a/alacritty/src/config/font.rs b/alacritty/src/config/font.rs index d554278c..061c0f42 100644 --- a/alacritty/src/config/font.rs +++ b/alacritty/src/config/font.rs @@ -134,7 +134,7 @@ struct Size(FontSize); impl Default for Size { fn default() -> Self { - Self(FontSize::new(11.)) + Self(FontSize::new(11.25)) } } diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index cf77e309..3b3d8297 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -463,9 +463,10 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon } } - fn change_font_size(&mut self, delta: i32) { - let new_size = (self.display.font_size.as_px() as i32 + delta).clamp(1, u16::MAX as i32); - self.display.font_size = FontSize::from_px(new_size as u16); + fn change_font_size(&mut self, delta: f32) { + // Round to pick integral px steps, since fonts look better on them. + let new_size = self.display.font_size.as_px().round() + delta; + self.display.font_size = FontSize::from_px(new_size); let font = self.config.font.clone().with_size(self.display.font_size); self.display.pending_update.set_font(font); } @@ -1168,8 +1169,7 @@ impl TouchZoom { // Calculate font change in `FONT_SIZE_STEP` increments. let delta = (self.distance() - old_distance) * TOUCH_ZOOM_FACTOR + self.fractions; - let font_delta = - (delta.abs() / FONT_SIZE_STEP as f32).floor() * FONT_SIZE_STEP as f32 * delta.signum(); + let font_delta = (delta.abs() / FONT_SIZE_STEP).floor() * FONT_SIZE_STEP * delta.signum(); self.fractions = delta - font_delta; font_delta diff --git a/alacritty/src/input/mod.rs b/alacritty/src/input/mod.rs index a465fd37..5e8a4bfd 100644 --- a/alacritty/src/input/mod.rs +++ b/alacritty/src/input/mod.rs @@ -48,7 +48,7 @@ use crate::scheduler::{Scheduler, TimerId, Topic}; pub mod keyboard; /// Font size change interval in px. -pub const FONT_SIZE_STEP: i32 = 1; +pub const FONT_SIZE_STEP: f32 = 1.; /// Interval for mouse scrolling during selection outside of the boundaries. const SELECTION_SCROLLING_INTERVAL: Duration = Duration::from_millis(15); @@ -98,7 +98,7 @@ pub trait ActionContext { fn create_new_window(&mut self, _tabbing_id: Option) {} #[cfg(not(target_os = "macos"))] fn create_new_window(&mut self) {} - fn change_font_size(&mut self, _delta: i32) {} + fn change_font_size(&mut self, _delta: f32) {} fn reset_font_size(&mut self) {} fn pop_message(&mut self) {} fn message(&self) -> Option<&Message>; @@ -865,7 +865,7 @@ impl> Processor { }, TouchPurpose::Zoom(zoom) => { let font_delta = zoom.font_delta(touch); - self.ctx.change_font_size(font_delta as i32); + self.ctx.change_font_size(font_delta); }, TouchPurpose::Scroll(last_touch) => { // Calculate delta and update last touch position. diff --git a/extra/man/alacritty.5.scd b/extra/man/alacritty.5.scd index f05773bc..272c861f 100644 --- a/extra/man/alacritty.5.scd +++ b/extra/man/alacritty.5.scd @@ -245,7 +245,7 @@ macOS: { family = _"Menlo"_, style = _"Regular"_ } Font size in points. - Default: _11.0_ + Default: _11.25_ *offset* = { x = __, y = __ }