From 8a88f7c6c49ff34cbf68e2e109196e9c420d8497 Mon Sep 17 00:00:00 2001 From: gcailly <109429289+gcailly@users.noreply.github.com> Date: Thu, 26 Mar 2026 15:19:19 +0100 Subject: [PATCH] Apply cargo fmt formatting fixes --- crates/epaint/src/text/font.rs | 3 +- crates/epaint/src/text/fonts.rs | 4 +- crates/epaint/src/text/text_layout.rs | 54 +++++++++++++++++++-------- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index d041f391f..8994ea699 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -606,8 +606,7 @@ impl FontFace { None } else { Some(harfrust::ShaperInstance::from_variations( - font_ref, - variations, + font_ref, variations, )) }; diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index 8254325b5..135ddb6d5 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -811,9 +811,7 @@ impl FontsImpl { /// Take the recycled shaping buffer (or create a new one if already taken). pub fn take_shape_buffer(&mut self) -> harfrust::UnicodeBuffer { - self.shape_buffer - .take() - .unwrap_or_default() + self.shape_buffer.take().unwrap_or_default() } /// Return a shaping buffer for reuse. diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs index bf3026200..a7a5caaef 100644 --- a/crates/epaint/src/text/text_layout.rs +++ b/crates/epaint/src/text/text_layout.rs @@ -227,11 +227,19 @@ fn layout_shaped_run( let fallback_metrics = font .fonts_by_id .get(&fallback_key) - .map(|ff| ff.styled_metrics(ctx.pixels_per_point, ctx.font_size, &Default::default())) + .map(|ff| { + ff.styled_metrics(ctx.pixels_per_point, ctx.font_size, &Default::default()) + }) .unwrap_or_default(); let (glyph_alloc, physical_x) = if let Some(ff) = font.fonts_by_id.get_mut(&fallback_key) { - ff.allocate_glyph(font.atlas, &fallback_metrics, glyph_info, chr, paragraph.cursor_x_px) + ff.allocate_glyph( + font.atlas, + &fallback_metrics, + glyph_info, + chr, + paragraph.cursor_x_px, + ) } else { Default::default() }; @@ -257,8 +265,13 @@ fn layout_shaped_run( let (glyph_alloc, physical_x) = if let Some(ff) = font.fonts_by_id.get_mut(&run.font_key) { ff.allocate_glyph_by_id( - font.atlas, face_metrics, glyph_id, x_advance_px, - h_pos, y_offset_points, is_cjk(chr), + font.atlas, + face_metrics, + glyph_id, + x_advance_px, + h_pos, + y_offset_points, + is_cjk(chr), ) } else { Default::default() @@ -360,12 +373,16 @@ fn layout_section( flags |= harfrust::BufferFlags::END_OF_TEXT; } - let glyph_buffer = - font_face.shape_text(run_text, &format.coords, shape_buffer, flags); + let glyph_buffer = font_face.shape_text(run_text, &format.coords, shape_buffer, flags); layout_shaped_run( - &mut font, run, run_text, &glyph_buffer, - &face_metrics, &mut ctx, paragraph, + &mut font, + run, + run_text, + &glyph_buffer, + &face_metrics, + &mut ctx, + paragraph, ); shape_buffer = glyph_buffer.clear(); @@ -1477,10 +1494,7 @@ mod tests { ); let glyphs = &galley_combined.rows[0].row.glyphs; - assert!( - !glyphs.is_empty(), - "Expected at least 1 glyph for ɔ̃" - ); + assert!(!glyphs.is_empty(), "Expected at least 1 glyph for ɔ̃"); } #[test] @@ -1575,10 +1589,18 @@ mod tests { for pair in ["AV", "VA", "AT"] { let (pair_w, _, _) = measure_text(&mut fonts, pair, &font_id, pixels_per_point); let chars: Vec = pair.chars().collect(); - let (w1, _, _) = - measure_text(&mut fonts, &chars[0].to_string(), &font_id, pixels_per_point); - let (w2, _, _) = - measure_text(&mut fonts, &chars[1].to_string(), &font_id, pixels_per_point); + let (w1, _, _) = measure_text( + &mut fonts, + &chars[0].to_string(), + &font_id, + pixels_per_point, + ); + let (w2, _, _) = measure_text( + &mut fonts, + &chars[1].to_string(), + &font_id, + pixels_per_point, + ); let sum = w1 + w2; let kern_adjustment = sum - pair_w;