From 0fd04c371a5d3fcd7cd9cf65a247fa16df0f0b5f Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Thu, 14 Dec 2023 07:15:40 +0400 Subject: Bump crossfont to 0.7.0 --- alacritty/src/config/font.rs | 2 +- alacritty/src/event.rs | 10 +++++----- alacritty/src/input/mod.rs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'alacritty/src') 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. -- cgit