From e801e484f14609cc365780735d0ca46389087d02 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 4 Mar 2025 04:54:13 -0700 Subject: [PATCH] [fontations] Remove get_glyph_h_advance() --- src/fontations/lib.rs | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/src/fontations/lib.rs b/src/fontations/lib.rs index 19ea8ca20..1e01a3b78 100644 --- a/src/fontations/lib.rs +++ b/src/fontations/lib.rs @@ -22,27 +22,6 @@ extern "C" fn _hb_fontations_data_destroy(ptr: *mut c_void) { // TODO } -extern "C" fn _hb_fontations_get_glyph_h_advance( - font: *mut hb_font_t, - font_data: *mut ::std::os::raw::c_void, - glyph: hb_codepoint_t, - _user_data: *mut ::std::os::raw::c_void, -) -> hb_position_t { - let data = unsafe { - assert!(!font_data.is_null()); - &*(font_data as *const FontationsData) - }; - let mut x_scale : i32 = 0; - let mut y_scale : i32 = 0; - unsafe { hb_font_get_scale(font, &mut x_scale, &mut y_scale); }; - let font_ref = &data.font_ref; - let size = Size::new(x_scale as f32); - let glyph_id = GlyphId::new(glyph); - let location = Location::default(); - let glyph_metrics = font_ref.glyph_metrics(size, &location); - let advance = glyph_metrics.advance_width(glyph_id).unwrap_or_default(); - advance as hb_position_t -} extern "C" fn _hb_fontations_get_glyph_h_advances( font: *mut hb_font_t, font_data: *mut ::std::os::raw::c_void, @@ -62,12 +41,12 @@ extern "C" fn _hb_fontations_get_glyph_h_advances( unsafe { hb_font_get_scale(font, &mut x_scale, &mut y_scale); }; let font_ref = &data.font_ref; let size = Size::new(x_scale as f32); - let location = Location::default(); + let location = Location::default(); // TODO + let glyph_metrics = font_ref.glyph_metrics(size, &location); for i in 0..count { let glyph = unsafe { *first_glyph.offset((i * glyph_stride) as isize) }; let glyph_id = GlyphId::new(glyph); - let glyph_metrics = font_ref.glyph_metrics(size, &location); let advance = glyph_metrics.advance_width(glyph_id).unwrap_or_default(); unsafe { *first_advance.offset((i * advance_stride) as isize) = advance as hb_position_t; } } @@ -77,18 +56,7 @@ fn _hb_fontations_font_funcs_create() -> *mut hb_font_funcs_t { let ffuncs = unsafe { hb_font_funcs_create() }; unsafe { - hb_font_funcs_set_glyph_h_advance_func( - ffuncs, - Some(_hb_fontations_get_glyph_h_advance), - null_mut(), - None - ); - hb_font_funcs_set_glyph_h_advances_func( - ffuncs, - Some(_hb_fontations_get_glyph_h_advances), - null_mut(), - None - ); + hb_font_funcs_set_glyph_h_advances_func(ffuncs, Some(_hb_fontations_get_glyph_h_advances), null_mut(), None); } ffuncs