From 74e99dbe6357c168eb50089e1fde58a67764f415 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 6 Jun 2025 18:15:20 -0600 Subject: [PATCH] [harfruzz] Apply review feedback --- src/rust/shape.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/rust/shape.rs b/src/rust/shape.rs index 5d5b2f18c..f4d31d3e0 100644 --- a/src/rust/shape.rs +++ b/src/rust/shape.rs @@ -54,7 +54,7 @@ pub struct HBHarfRuzzFontData { shaper_instance: ShaperInstance, } -fn font_coords_to_f2dot14(font: *mut hb_font_t) -> Vec { +fn font_to_shaper_instance(font: *mut hb_font_t, font_ref: &FontRef<'_>) -> ShaperInstance { let mut num_coords: u32 = 0; let coords = unsafe { hb_font_get_var_coords_normalized(font, &mut num_coords) }; let coords = if coords.is_null() { @@ -62,10 +62,8 @@ fn font_coords_to_f2dot14(font: *mut hb_font_t) -> Vec { } else { unsafe { std::slice::from_raw_parts(coords, num_coords as usize) } }; - coords - .iter() - .map(|&v| NormalizedCoord::from_bits(v as i16)) - .collect::>() + let coords = coords.iter().map(|&v| NormalizedCoord::from_bits(v as i16)); + ShaperInstance::from_coords(font_ref, coords) } #[no_mangle] @@ -76,9 +74,7 @@ pub unsafe extern "C" fn _hb_harfruzz_shaper_font_data_create_rs( let face_data = face_data as *const HBHarfRuzzFaceData; let font_ref = &(*face_data).font_ref; - let coords = font_coords_to_f2dot14(font); - - let shaper_instance = ShaperInstance::from_coords(font_ref, coords); + let shaper_instance = font_to_shaper_instance(font, font_ref); let hr_font_data = Box::new(HBHarfRuzzFontData { shaper_instance }); let hr_font_data_ptr = Box::into_raw(hr_font_data);