summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-09-03 00:59:49 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-09-03 00:59:56 +0200
commite1ff3f8a97be35be1f867e704b08f2cb168242de (patch)
treea29f6ed0de7e2fc408e5b4a82e4ebb297559bdb4 /examples
parentc7956cf526a748dac88f6619488f6ee49ff53331 (diff)
downloadiced-e1ff3f8a97be35be1f867e704b08f2cb168242de.tar.gz
iced-e1ff3f8a97be35be1f867e704b08f2cb168242de.tar.bz2
iced-e1ff3f8a97be35be1f867e704b08f2cb168242de.zip
Update `ggez` example to `FontCache` changes
Diffstat (limited to 'examples')
-rw-r--r--examples/ggez/renderer/text.rs16
1 files changed, 8 insertions, 8 deletions
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,