mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-22 23:41:03 +01:00
[harfruzz] Cache Face
This commit is contained in:
1 parent
b50b5a0db1
commit
a78d2f27ab
1 file changed
+6
-12
+6
-12
@@ -7,12 +7,11 @@ use std::ptr::null_mut;
|
||||
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 @@ pub unsafe extern "C" fn _hb_harfruzz_shaper_face_data_create_rs(
|
||||
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 @@ pub unsafe extern "C" fn _hb_harfruzz_shape_rs(
|
||||
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(
|
||||
|
||||
Reference in new issue
Block a user