From 84f57ac8367e3e24e0347515e6681c0478fc3d29 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Thu, 27 Feb 2020 00:29:14 +0300 Subject: Add FreeType face cache --- font/src/lib.rs | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) (limited to 'font/src/lib.rs') diff --git a/font/src/lib.rs b/font/src/lib.rs index f5dc0191..5ed255ad 100644 --- a/font/src/lib.rs +++ b/font/src/lib.rs @@ -21,7 +21,6 @@ #![deny(clippy::all, clippy::if_not_else, clippy::enum_glob_use, clippy::wrong_pub_self_convention)] use std::fmt; -use std::hash::{Hash, Hasher}; use std::ops::{Add, Mul}; use std::sync::atomic::{AtomicUsize, Ordering}; @@ -97,7 +96,7 @@ impl fmt::Display for FontDesc { /// Identifier for a Font for use in maps/etc #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub struct FontKey { - token: u16, + token: u32, } impl FontKey { @@ -111,39 +110,13 @@ impl FontKey { } } -#[derive(Debug, Copy, Clone, Eq)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct GlyphKey { pub c: char, pub font_key: FontKey, pub size: Size, } -impl Hash for GlyphKey { - fn hash(&self, state: &mut H) { - unsafe { - // This transmute is fine: - // - // - If GlyphKey ever becomes a different size, this will fail to compile - // - Result is being used for hashing and has no fields (it's a u64) - ::std::mem::transmute::(*self) - } - .hash(state); - } -} - -impl PartialEq for GlyphKey { - fn eq(&self, other: &Self) -> bool { - unsafe { - // This transmute is fine: - // - // - If GlyphKey ever becomes a different size, this will fail to compile - // - Result is being used for equality checking and has no fields (it's a u64) - let other = ::std::mem::transmute::(*other); - ::std::mem::transmute::(*self).eq(&other) - } - } -} - /// Font size stored as integer #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct Size(i16); -- cgit