Allow negative offsets

This commit is contained in:
grovesNL 2022-10-25 23:38:12 -02:30 committed by Josh Groves
parent dcdb250e19
commit 47fa03d079
2 changed files with 9 additions and 9 deletions

View file

@ -76,7 +76,7 @@ async fn run() {
TextMetrics::new(32, 44), TextMetrics::new(32, 44),
); );
buffer.set_size(800, 600); buffer.set_size(800, 600);
buffer.set_text(include_str!("./arabic.txt")); buffer.set_text(include_str!("./ligature.txt"));
buffer.shape_until_cursor(); buffer.shape_until_cursor();
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {

View file

@ -212,10 +212,10 @@ impl TextRenderer {
for (buffer, overflow) in buffers.iter() { for (buffer, overflow) in buffers.iter() {
// Note: subpixel positioning is not currently handled, so we always truncate down to // Note: subpixel positioning is not currently handled, so we always truncate down to
// the nearest pixel. // the nearest pixel.
let bounds_min_x = 0u32; let bounds_min_x = i32::MIN;
let bounds_max_x = u32::MAX; let bounds_max_x = i32::MAX;
let bounds_min_y = 0u32; let bounds_min_y = i32::MIN;
let bounds_max_y = u32::MAX; let bounds_max_y = i32::MAX;
for run in buffer.layout_runs() { for run in buffer.layout_runs() {
let line_y = run.line_y; let line_y = run.line_y;
@ -223,16 +223,16 @@ impl TextRenderer {
for glyph in run.glyphs.iter() { for glyph in run.glyphs.iter() {
let details = atlas.glyph_cache.get(&glyph.cache_key).unwrap(); let details = atlas.glyph_cache.get(&glyph.cache_key).unwrap();
let mut x = (glyph.x_int + details.left 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) as u32; let mut y = line_y + glyph.y_int - details.top as i32;
let (mut atlas_x, mut atlas_y) = match details.gpu_cache { let (mut atlas_x, mut atlas_y) = match details.gpu_cache {
GpuCache::InAtlas { x, y } => (x, y), GpuCache::InAtlas { x, y } => (x, y),
GpuCache::SkipRasterization => continue, GpuCache::SkipRasterization => continue,
}; };
let mut width = details.width as u32; let mut width = details.width as i32;
let mut height = details.height as u32; let mut height = details.height as i32;
match overflow { match overflow {
TextOverflow::Overflow => {} TextOverflow::Overflow => {}