From 47fa03d0797e9ccbdced762e7d85f6918a615788 Mon Sep 17 00:00:00 2001 From: grovesNL Date: Tue, 25 Oct 2022 23:38:12 -0230 Subject: [PATCH] Allow negative offsets --- examples/hello-world.rs | 2 +- src/text_render.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/hello-world.rs b/examples/hello-world.rs index ccb27ec..cd8bb18 100644 --- a/examples/hello-world.rs +++ b/examples/hello-world.rs @@ -76,7 +76,7 @@ async fn run() { TextMetrics::new(32, 44), ); buffer.set_size(800, 600); - buffer.set_text(include_str!("./arabic.txt")); + buffer.set_text(include_str!("./ligature.txt")); buffer.shape_until_cursor(); event_loop.run(move |event, _, control_flow| { diff --git a/src/text_render.rs b/src/text_render.rs index 5f83626..a0fe7f4 100644 --- a/src/text_render.rs +++ b/src/text_render.rs @@ -212,10 +212,10 @@ impl TextRenderer { for (buffer, overflow) in buffers.iter() { // Note: subpixel positioning is not currently handled, so we always truncate down to // the nearest pixel. - let bounds_min_x = 0u32; - let bounds_max_x = u32::MAX; - let bounds_min_y = 0u32; - let bounds_max_y = u32::MAX; + let bounds_min_x = i32::MIN; + let bounds_max_x = i32::MAX; + let bounds_min_y = i32::MIN; + let bounds_max_y = i32::MAX; for run in buffer.layout_runs() { let line_y = run.line_y; @@ -223,16 +223,16 @@ impl TextRenderer { for glyph in run.glyphs.iter() { let details = atlas.glyph_cache.get(&glyph.cache_key).unwrap(); - let mut x = (glyph.x_int + details.left as i32) as u32; - let mut y = (line_y + glyph.y_int - details.top as i32) as u32; + let mut x = glyph.x_int + details.left as i32; + let mut y = line_y + glyph.y_int - details.top as i32; let (mut atlas_x, mut atlas_y) = match details.gpu_cache { GpuCache::InAtlas { x, y } => (x, y), GpuCache::SkipRasterization => continue, }; - let mut width = details.width as u32; - let mut height = details.height as u32; + let mut width = details.width as i32; + let mut height = details.height as i32; match overflow { TextOverflow::Overflow => {}