From 2f0e6c75ce52e7dc3a908df078efa24149f58e5f Mon Sep 17 00:00:00 2001 From: Madeline Sparkles Date: Thu, 18 Jul 2024 00:08:40 +0800 Subject: [PATCH] oops! scale factor wasnt handled corrrectly in render_text! --- crates/yakui-widgets/src/widgets/render_text.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/yakui-widgets/src/widgets/render_text.rs b/crates/yakui-widgets/src/widgets/render_text.rs index f85957b4..368feccb 100644 --- a/crates/yakui-widgets/src/widgets/render_text.rs +++ b/crates/yakui-widgets/src/widgets/render_text.rs @@ -157,7 +157,7 @@ impl Widget for RenderTextWidget { let size_y = buffer.layout_runs().map(|layout| layout.line_height).sum(); - Vec2::new(size_x, size_y) + Vec2::new(size_x, size_y) / ctx.layout.scale_factor() }; let size = constraints.constrain(size); @@ -207,13 +207,17 @@ fn paint_text( layout_pos: Vec2, line_y: f32, ) { + let inv_scale_factor = 1.0 / ctx.layout.scale_factor(); + let size = render.rect.size().as_vec2(); + let physical = glyph.physical((0.0, 0.0), 1.0); let pos = Vec2::new(physical.x as f32, physical.y as f32); let mut rect = PaintRect::new(Rect::from_pos_size( - Vec2::new(pos.x + render.offset.x, pos.y - render.offset.y + line_y) + layout_pos, - Vec2::new(size.x, size.y), + Vec2::new(pos.x + render.offset.x, pos.y - render.offset.y + line_y) * inv_scale_factor + + layout_pos, + Vec2::new(size.x, size.y) * inv_scale_factor, )); if render.kind == Kind::Mask {