rhwp 0.9.1

HWP/HWPX document engine for Rust applications, WebAssembly, and CLI automation
Documentation
//! 실제 공급 프로그램을 대조한 host 관측을 공통 조판 환경에 전달한다.

use super::HwpDocument;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
impl HwpDocument {
    /// 실제 로드한 보통 FontFace의 주 프로그램을 Print paint에만 연결한다.
    /// complete가 false이면 결측 glyph를 뒤 family의 glyph로 추정하지 않는다.
    #[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);
    }

    /// 페이지별 host FontFace 공급의 수명이 끝나면 그 주 프로그램 증거를 폐기한다.
    #[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);
    }

    /// 같은 cmap 판정으로 아직 공급되지 않은 글리프만 다음 후보에 전달한다.
    #[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)
    }

    /// WMF 공백 글리프도 실제 cmap으로 대조한다.
    #[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,
        )
    }

    /// 공급 후보를 등록하기 전에 실제 cmap를 대조한다. CSS 이름 검사가 아니다.
    #[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)
    }

    /// FontFace와 Native fallback이 같은 실제 기호 공급 판정을 사용한다.
    #[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()))
    }

    /// 호출자는 원 face 부재·실제 대체 프로그램·입력 대응을 확인한 관측만 전달한다.
    #[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)
    }
}