Update ggez example to FontCache changes
This commit is contained in:
parent
c7956cf526
commit
e1ff3f8a97
2 changed files with 9 additions and 9 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue