Somehow the text doesn’t show. Can you give me some suggestions, please? It is supposed to be a text “yrs - Rust.pdf” in the tiny rectangle in the center of this window.
As you can see the text layout is correct below:
pub fn draw<Renderer>(
renderer: &mut Renderer,
style: &renderer::Style,
layout: Layout<'_>,
state: &State<Renderer::Paragraph>,
appearance: Style,
viewport: &Rectangle,
) where
Renderer: text::Renderer,
{
let State(ref paragraph) = state;
let bounds = layout.bounds();
let x = match paragraph.horizontal_alignment() {
alignment::Horizontal::Left => bounds.x,
alignment::Horizontal::Center => bounds.center_x(),
alignment::Horizontal::Right => bounds.x + bounds.width,
};
let y = match paragraph.vertical_alignment() {
alignment::Vertical::Top => bounds.y,
alignment::Vertical::Center => bounds.center_y(),
alignment::Vertical::Bottom => bounds.y + bounds.height,
};
dbg!(layout, x, y, style.text_color, *viewport, appearance);
renderer.fill_paragraph(
paragraph,
Point::new(x, y),
appearance.color.unwrap_or(style.text_color),
*viewport,
);
}
[/Users/john/Workspace/iced/core/src/widget/text.rs:297:5] layout = Layout {
position: Point {
x: 124.1416,
y: 376.6,
},
node: Node {
bounds: Rectangle {
x: 124.1416,
y: 376.6,
width: 151.7168,
height: 23.4,
},
children: [],
},
}
[/Users/john/Workspace/iced/core/src/widget/text.rs:297:5] x = 124.1416
[/Users/john/Workspace/iced/core/src/widget/text.rs:297:5] y = 376.6
[/Users/john/Workspace/iced/core/src/widget/text.rs:297:5] style.text_color = Color {
r: 0.0,
g: 0.0,
b: 0.0,
a: 1.0,
}
[/Users/john/Workspace/iced/core/src/widget/text.rs:297:5] *viewport = Rectangle {
x: 0.0,
y: 0.0,
width: 756.0,
height: 944.0,
}
[/Users/john/Workspace/iced/core/src/widget/text.rs:297:5] appearance = Style {
color: Some(
Color {
r: 0.0,
g: 0.0,
b: 0.0,
a: 1.0,
},
),
}
aso here is the text from the log :
TRACE iced_graphics::text::paragraph > Allocating paragraph: yrs - Rust.pdf