summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Cargo.toml2
-rw-r--r--examples/ggez/renderer/text.rs16
2 files changed, 9 insertions, 9 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 9359a086..82279f05 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,4 +19,4 @@ twox-hash = "1.5"
winit = { version = "0.20.0-alpha3", optional = true }
[dev-dependencies]
-ggez = { version = "0.5", git = "https://github.com/hecrj/ggez" }
+ggez = { version = "0.5", git = "https://github.com/hecrj/ggez.git", branch = "font-cache" }
diff --git a/examples/ggez/renderer/text.rs b/examples/ggez/renderer/text.rs
index 7eab91fc..a6f782fc 100644
--- a/examples/ggez/renderer/text.rs
+++ b/examples/ggez/renderer/text.rs
@@ -9,16 +9,16 @@ impl text::Renderer<Color> for Renderer<'_> {
fn node(&self, style: iced::Style, content: &str, size: f32) -> iced::Node {
let font_cache = graphics::font_cache(self.context);
let content = String::from(content);
+
+ // TODO: Investigate why stretch tries to measure this MANY times
+ // with every ancestor's bounds.
+ // Bug? Using the library wrong? I should probably open an issue on
+ // the stretch repository.
+ // I noticed that the first measure is the one that matters in
+ // practice. Here, we use a RefCell to store the cached measurement.
let measure = RefCell::new(None);
iced::Node::with_measure(style, move |bounds| {
- // TODO: Investigate why stretch tries to measure this MANY times
- // with every ancestor's bounds.
- // Bug? Using the library wrong? I should probably open an issue on
- // the stretch repository.
- // I noticed that the first measure is the one that matters in
- // practice. Here, we use a RefCell to store the cached
- // measurement.
let mut measure = measure.borrow_mut();
if measure.is_none() {
@@ -47,7 +47,7 @@ impl text::Renderer<Color> for Renderer<'_> {
Align::Left,
);
- let (width, height) = text.dimensions(&font_cache);
+ let (width, height) = font_cache.dimensions(&text);
let size = iced::Size {
width: width as f32,