use super::HwpDocument;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
impl HwpDocument {
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen(js_name = registerPrintFontPrimary)]
pub fn register_print_font_primary(
&mut self,
family: &str,
bytes: &[u8],
index: u32,
complete: bool,
) {
self.core
.hft_outline_fonts
.register_print_primary(family, bytes, index, complete);
}
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen(js_name = clearPrintFontPrimary)]
pub fn clear_print_font_primary(&mut self, family: &str) {
self.core.hft_outline_fonts.clear_print_primary(family);
}
#[wasm_bindgen(js_name = fontMissingText)]
pub fn font_missing_text_js(
&self,
bytes: &[u8],
face_index: u32,
text: &str,
) -> Option<String> {
crate::renderer::font_symbol_coverage::font_missing_text(bytes, face_index, text)
}
#[wasm_bindgen(js_name = fontMissingTextWithSpaces)]
pub fn font_missing_text_with_spaces_js(
&self,
bytes: &[u8],
face_index: u32,
text: &str,
) -> Option<String> {
crate::renderer::font_symbol_coverage::font_missing_text_with_spaces(
bytes, face_index, text,
)
}
#[wasm_bindgen(js_name = fontSupportsText)]
pub fn font_supports_text_js(&self, bytes: &[u8], face_index: u32, text: &str) -> bool {
crate::renderer::font_symbol_coverage::font_supports_text(bytes, face_index, text)
}
#[wasm_bindgen(js_name = getFontSymbolUnicodeRange)]
pub fn get_font_symbol_unicode_range_js(&self, bytes: &[u8], face_index: u32) -> String {
crate::renderer::font_symbol_coverage::font_symbol_unicode_range(bytes, face_index)
}
#[wasm_bindgen(js_name = getDeclaredFontFallbackRequests)]
pub fn get_declared_font_fallback_requests_js(&self) -> Result<String, JsValue> {
serde_json::to_string(&self.declared_font_fallback_requests())
.map_err(|e| JsValue::from_str(&e.to_string()))
}
#[wasm_bindgen(js_name = setObservedFontFallbacks)]
pub fn set_observed_font_fallbacks_js(&mut self, json: &str) -> Result<bool, JsValue> {
self.set_observed_font_fallbacks_native(json)
.map_err(JsValue::from)
}
}