diff options
author | 2023-02-04 11:21:35 +0100 | |
---|---|---|
committer | 2023-02-24 13:29:12 +0100 | |
commit | 5a82fc654e2933c4c93dac5393685861feb07b1f (patch) | |
tree | c7d77ad8b7ad87a296d1efd473234382614b5fd8 | |
parent | 238154af4ac8dda7f12dd90aa7be106e933bcb30 (diff) | |
download | iced-5a82fc654e2933c4c93dac5393685861feb07b1f.tar.gz iced-5a82fc654e2933c4c93dac5393685861feb07b1f.tar.bz2 iced-5a82fc654e2933c4c93dac5393685861feb07b1f.zip |
Use floating coordinates directly in `text::Pipeline`
-rw-r--r-- | wgpu/Cargo.toml | 3 | ||||
-rw-r--r-- | wgpu/src/text.rs | 13 |
2 files changed, 8 insertions, 8 deletions
diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index dffbbab0..280ce29b 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -52,7 +52,8 @@ path = "../graphics" [dependencies.glyphon] version = "0.2" -path = "../../glyphon" +git = "https://github.com/hecrj/glyphon.git" +rev = "bffca9b958af11d1bfd0c0d1a281fc8799cc5a5b" [dependencies.tracing] version = "0.1.6" diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index cdfcd576..2ca3f0d8 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -276,7 +276,7 @@ impl Pipeline { }, ); - let cursor = paragraph.hit(point.x as i32, point.y as i32)?; + let cursor = paragraph.hit(point.x, point.y)?; Some(Hit::CharOffset(cursor.index)) }) @@ -329,21 +329,20 @@ impl<'a> Cache<'a> { let mut hasher = self.hasher.build_hasher(); key.content.hash(&mut hasher); - (key.size as i32).hash(&mut hasher); + key.size.to_bits().hash(&mut hasher); key.font.hash(&mut hasher); - (key.bounds.width as i32).hash(&mut hasher); - (key.bounds.height as i32).hash(&mut hasher); + key.bounds.width.to_bits().hash(&mut hasher); + key.bounds.height.to_bits().hash(&mut hasher); key.color.into_rgba8().hash(&mut hasher); hasher.finish() }; if !self.entries.contains_key(&hash) { - let metrics = - glyphon::Metrics::new(key.size as i32, (key.size * 1.2) as i32); + let metrics = glyphon::Metrics::new(key.size, key.size * 1.2); let mut buffer = glyphon::Buffer::new(&fonts, metrics); - buffer.set_size(key.bounds.width as i32, key.bounds.height as i32); + buffer.set_size(key.bounds.width, key.bounds.height); buffer.set_text( key.content, glyphon::Attrs::new().family(to_family(key.font)).color({ |