skia_safe/modules/shaper/
harfbuzz.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use skia_bindings as sb;

use super::ScriptRunIterator;
use crate::{prelude::*, Borrows, FontMgr, FourByteTag, Shaper};

pub fn shaper_driven_wrapper(fallback_font_mgr: impl Into<Option<FontMgr>>) -> Option<Shaper> {
    #[cfg(feature = "embed-icudtl")]
    crate::icu::init();

    Shaper::from_ptr(unsafe {
        sb::C_SkShapers_HB_ShaperDrivenWrapper(fallback_font_mgr.into().into_ptr_or_null())
    })
}

pub fn shape_then_wrap(fallback_font_mgr: impl Into<Option<FontMgr>>) -> Option<Shaper> {
    #[cfg(feature = "embed-icudtl")]
    crate::icu::init();

    Shaper::from_ptr(unsafe {
        sb::C_SkShapers_HB_ShapeThenWrap(fallback_font_mgr.into().into_ptr_or_null())
    })
}

pub fn shape_dont_wrap_or_reorder(fallback_font_mgr: impl Into<Option<FontMgr>>) -> Option<Shaper> {
    #[cfg(feature = "embed-icudtl")]
    crate::icu::init();

    Shaper::from_ptr(unsafe {
        sb::C_SkShapers_HB_ShapeDontWrapOrReorder(fallback_font_mgr.into().into_ptr_or_null())
    })
}

pub fn script_run_iterator(
    utf8: &str,
    script: impl Into<Option<FourByteTag>>,
) -> Borrows<ScriptRunIterator> {
    let script = script.into();
    if let Some(tag) = script {
        Shaper::new_script_run_iterator(utf8, tag)
    } else {
        Shaper::new_hb_icu_script_run_iterator(utf8)
    }
}