diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2023-12-14 07:15:40 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-14 07:15:40 +0400 |
commit | 0fd04c371a5d3fcd7cd9cf65a247fa16df0f0b5f (patch) | |
tree | 6f19a8821648dff830c5f948c5c0b073217fdd5b /alacritty/src | |
parent | c0c267d60e1b877d5c2c76893751d13547a233c4 (diff) | |
download | r-alacritty-0fd04c371a5d3fcd7cd9cf65a247fa16df0f0b5f.tar.gz r-alacritty-0fd04c371a5d3fcd7cd9cf65a247fa16df0f0b5f.tar.bz2 r-alacritty-0fd04c371a5d3fcd7cd9cf65a247fa16df0f0b5f.zip |
Bump crossfont to 0.7.0
Diffstat (limited to 'alacritty/src')
-rw-r--r-- | alacritty/src/config/font.rs | 2 | ||||
-rw-r--r-- | alacritty/src/event.rs | 10 | ||||
-rw-r--r-- | alacritty/src/input/mod.rs | 6 |
3 files changed, 9 insertions, 9 deletions
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<T> 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<T: EventListener> { fn create_new_window(&mut self, _tabbing_id: Option<String>) {} #[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<T: EventListener, A: ActionContext<T>> Processor<T, A> { }, 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. |