Use floating coordinates directly in text::Pipeline

This commit is contained in:
Héctor Ramón Jiménez 2023-02-04 11:21:35 +01:00
parent 238154af4a
commit 5a82fc654e
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 8 additions and 8 deletions

View file

@ -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"

View file

@ -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({