Reuse entries in text::Cache in iced_wgpu
This commit is contained in:
parent
af62ec1c87
commit
78ad365db2
10 changed files with 69 additions and 46 deletions
|
|
@ -64,8 +64,8 @@ impl text::Renderer for Null {
|
|||
_font: Font,
|
||||
_bounds: Size,
|
||||
_shaping: text::Shaping,
|
||||
) -> (f32, f32) {
|
||||
(0.0, 20.0)
|
||||
) -> Size {
|
||||
Size::new(0.0, 20.0)
|
||||
}
|
||||
|
||||
fn hit_test(
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ pub trait Renderer: crate::Renderer {
|
|||
font: Self::Font,
|
||||
bounds: Size,
|
||||
shaping: Shaping,
|
||||
) -> (f32, f32);
|
||||
) -> Size;
|
||||
|
||||
/// Measures the width of the text as if it were laid out in a single line.
|
||||
fn measure_width(
|
||||
|
|
@ -173,7 +173,7 @@ pub trait Renderer: crate::Renderer {
|
|||
font: Self::Font,
|
||||
shaping: Shaping,
|
||||
) -> f32 {
|
||||
let (width, _) = self.measure(
|
||||
let bounds = self.measure(
|
||||
content,
|
||||
size,
|
||||
LineHeight::Absolute(Pixels(size)),
|
||||
|
|
@ -182,7 +182,7 @@ pub trait Renderer: crate::Renderer {
|
|||
shaping,
|
||||
);
|
||||
|
||||
width
|
||||
bounds.width
|
||||
}
|
||||
|
||||
/// Tests whether the provided point is within the boundaries of text
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crate::mouse;
|
|||
use crate::renderer;
|
||||
use crate::text;
|
||||
use crate::widget::Tree;
|
||||
use crate::{Color, Element, Layout, Length, Pixels, Rectangle, Size, Widget};
|
||||
use crate::{Color, Element, Layout, Length, Pixels, Rectangle, Widget};
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
|
|
@ -139,18 +139,16 @@ where
|
|||
|
||||
let size = self.size.unwrap_or_else(|| renderer.default_size());
|
||||
|
||||
let bounds = limits.max();
|
||||
|
||||
let (width, height) = renderer.measure(
|
||||
let bounds = renderer.measure(
|
||||
&self.content,
|
||||
size,
|
||||
self.line_height,
|
||||
self.font.unwrap_or_else(|| renderer.default_font()),
|
||||
bounds,
|
||||
limits.max(),
|
||||
self.shaping,
|
||||
);
|
||||
|
||||
let size = limits.resolve(Size::new(width, height));
|
||||
let size = limits.resolve(bounds);
|
||||
|
||||
layout::Node::new(size)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue