git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commita0ed5e140a4c81d191154fcd73c49075e56a9fd4
parent59cb9ee215
authorLucas Galante <[email protected]>
date2026-07-02 23:04
Scaled cached character offsets by DPI scale_factor to convert shaper physical coordinates back to logical pixels

 src/widget/input/text_box.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/widget/input/text_box.rs b/src/widget/input/text_box.rs
index 0daf813..3224a7a 100644
--- a/src/widget/input/text_box.rs
+++ b/src/widget/input/text_box.rs
@@ -515,15 +515,16 @@ impl Element for TextBox {
         let char_count = render_text.chars().count();
         let mut x_offsets = vec![0.0; char_count + 1];
         let mut total_w: f32 = 0.0;
+        let scale = crate::scale::scale_factor().max(1.0);
 
         for run in buffer.layout_runs() {
             for glyph in run.glyphs {
                 let byte_offset = glyph.start;
                 let c_idx = render_text[..byte_offset.min(render_text.len())].chars().count();
                 if c_idx < x_offsets.len() {
-                    x_offsets[c_idx] = glyph.x;
+                    x_offsets[c_idx] = glyph.x / scale;
                 }
-                total_w = total_w.max(glyph.x + glyph.w);
+                total_w = total_w.max((glyph.x + glyph.w) / scale);
             }
         }