[harfruzz] Cache Face
diff --git a/src/rust/shape.rs b/src/rust/shape.rs
index 823591b..2e66de0 100644
--- a/src/rust/shape.rs
+++ b/src/rust/shape.rs
@@ -7,12 +7,11 @@
use std::str::FromStr;
use font_types::Tag;
-use harfruzz::{Direction, FontRef, Language, Script, ShaperFont};
+use harfruzz::{Direction, Face, FontRef, Language, Script, ShaperFont};
pub struct HBHarfRuzzFaceData<'a> {
face_blob: *mut hb_blob_t,
- font_ref: FontRef<'a>,
- shaper_font: ShaperFont,
+ face: Face<'a>,
}
#[no_mangle]
@@ -28,12 +27,9 @@
let font_ref = FontRef::from_index(face_data, face_index)
.expect("FontRef::from_index should succeed on valid HarfBuzz face data");
let shaper_font = ShaperFont::new(&font_ref);
+ let face = shaper_font.shaper(&font_ref, &[]);
- let hr_face_data = HBHarfRuzzFaceData {
- face_blob,
- font_ref,
- shaper_font,
- };
+ let hr_face_data = HBHarfRuzzFaceData { face_blob, face };
let hr_face_data_ptr = Box::into_raw(Box::new(hr_face_data));
hr_face_data_ptr as *mut c_void
}
@@ -99,11 +95,9 @@
hr_buffer.add(char::from_u32_unchecked(unicode), cluster);
}
- let font_ref = &(*data).font_ref;
- let shaper_font = &(*data).shaper_font;
- let face = shaper_font.shaper(font_ref, &[]);
+ let face = &(*data).face;
- let glyphs = harfruzz::shape(&face, &[], hr_buffer);
+ let glyphs = harfruzz::shape(face, &[], hr_buffer);
let count = glyphs.len();
hb_buffer_set_content_type(