rhwp 0.9.0

HWP/HWPX document engine for Rust applications, WebAssembly, and CLI automation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Native와 같은 Print 기하 정책을 Canvas의 표준 래스터 힌트로 전달한다.
use wasm_bindgen::JsValue;
use web_sys::CanvasRenderingContext2d;

pub(super) fn configure(context: &CanvasRenderingContext2d, preserve_geometry: bool) {
    let property = JsValue::from_str("textRendering");
    if !js_sys::Reflect::has(context.as_ref(), &property).unwrap_or(false) {
        return;
    }
    let mode = if preserve_geometry {
        "geometricPrecision"
    } else {
        "auto"
    };
    let _ = js_sys::Reflect::set(context.as_ref(), &property, &JsValue::from_str(mode));
}