[wasm-rust] update font_copy_table API

This commit is contained in:
Simon Cozens 2023-02-25 15:38:08 +00:00 committed by Behdad Esfahbod
parent db789eacb4
commit 92a57b4b4a
1 changed files with 9 additions and 2 deletions

View File

@ -41,7 +41,7 @@ extern "C" {
fn font_glyph_to_string(font: u32, glyph: u32, str: *const u8, len: u32);
fn font_get_glyph_h_advance(font: u32, glyph: u32) -> i32;
fn font_get_glyph_v_advance(font: u32, glyph: u32) -> i32;
fn face_copy_table(font: u32, tag: u32) -> Blob;
fn face_copy_table(font: u32, tag: u32, blob: *mut Blob) -> bool;
fn buffer_copy_contents(buffer: u32, cbuffer: *mut CBufferContents) -> bool;
fn buffer_set_contents(buffer: u32, cbuffer: &CBufferContents) -> bool;
fn debugprint(s: *const u8);
@ -165,7 +165,14 @@ impl Face {
tag_u |= (chars.next().unwrap() as u32) << 16;
tag_u |= (chars.next().unwrap() as u32) << 8;
tag_u |= chars.next().unwrap() as u32;
unsafe { face_copy_table(self.0, tag_u) }
let mut blob = Blob {
data: std::ptr::null_mut(),
length: 0,
};
unsafe {
face_copy_table(self.0, tag_u, &mut blob);
}
blob
}
/// Get the face's design units per em.