diff options
author | Christian Duerr <contact@christianduerr.com> | 2019-10-05 02:29:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-05 02:29:26 +0200 |
commit | 729eef0c933831bccfeac6a355bdb410787fbe5f (patch) | |
tree | 35cdf2e6427ad18bc53efbab4cab34a0af2054d7 /font | |
parent | b0c6fdff763f7271506d26d7e768e6377fdc691b (diff) | |
download | alacritty-729eef0c933831bccfeac6a355bdb410787fbe5f.tar.gz alacritty-729eef0c933831bccfeac6a355bdb410787fbe5f.zip |
Update to winit/glutin EventLoop 2.0
This takes the latest glutin master to port Alacritty to the EventLoop
2.0 rework.
This changes a big part of the event loop handling by pushing the event
loop in a separate thread from the renderer and running both in
parallel.
Fixes #2796.
Fixes #2694.
Fixes #2643.
Fixes #2625.
Fixes #2618.
Fixes #2601.
Fixes #2564.
Fixes #2456.
Fixes #2438.
Fixes #2334.
Fixes #2254.
Fixes #2217.
Fixes #1789.
Fixes #1750.
Fixes #1125.
Diffstat (limited to 'font')
-rw-r--r-- | font/src/darwin/mod.rs | 11 | ||||
-rw-r--r-- | font/src/ft/mod.rs | 2 | ||||
-rw-r--r-- | font/src/lib.rs | 31 |
3 files changed, 29 insertions, 15 deletions
diff --git a/font/src/darwin/mod.rs b/font/src/darwin/mod.rs index 42927654..dae7ee04 100644 --- a/font/src/darwin/mod.rs +++ b/font/src/darwin/mod.rs @@ -591,12 +591,11 @@ mod tests { let index = ((glyph.width * 3 * row) + (col * 3)) as usize; let value = glyph.buf[index]; let c = match value { - 0...50 => ' ', - 51...100 => '.', - 101...150 => '~', - 151...200 => '*', - 201...255 => '#', - _ => unreachable!(), + 0..=50 => ' ', + 51..=100 => '.', + 101..=150 => '~', + 151..=200 => '*', + 201..=255 => '#', }; print!("{}", c); } diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs index 5388aeb4..0886f177 100644 --- a/font/src/ft/mod.rs +++ b/font/src/ft/mod.rs @@ -546,7 +546,7 @@ pub enum Error { } impl ::std::error::Error for Error { - fn cause(&self) -> Option<&dyn (::std::error::Error)> { + fn cause(&self) -> Option<&dyn std::error::Error> { match *self { Error::FreeType(ref err) => Some(err), _ => None, diff --git a/font/src/lib.rs b/font/src/lib.rs index d3bddd54..262cf911 100644 --- a/font/src/lib.rs +++ b/font/src/lib.rs @@ -47,6 +47,7 @@ extern crate log; use std::fmt; use std::hash::{Hash, Hasher}; +use std::ops::{Add, Mul}; use std::sync::atomic::{AtomicUsize, Ordering}; // If target isn't macos or windows, reexport everything from ft @@ -173,28 +174,42 @@ impl PartialEq for GlyphKey { pub struct Size(i16); impl Size { + /// Create a new `Size` from a f32 size in points + pub fn new(size: f32) -> Size { + Size((size * Size::factor()) as i16) + } + /// Scale factor between font "Size" type and point size #[inline] pub fn factor() -> f32 { 2.0 } - /// Create a new `Size` from a f32 size in points - pub fn new(size: f32) -> Size { - Size((size * Size::factor()) as i16) - } - /// Get the f32 size in points pub fn as_f32_pts(self) -> f32 { f32::from(self.0) / Size::factor() } } -impl ::std::ops::Add for Size { +impl<T: Into<Size>> Add<T> for Size { type Output = Size; - fn add(self, other: Size) -> Size { - Size(self.0.saturating_add(other.0)) + fn add(self, other: T) -> Size { + Size(self.0.saturating_add(other.into().0)) + } +} + +impl<T: Into<Size>> Mul<T> for Size { + type Output = Size; + + fn mul(self, other: T) -> Size { + Size(self.0 * other.into().0) + } +} + +impl From<f32> for Size { + fn from(float: f32) -> Size { + Size::new(float) } } |