skia_safe/modules/shaper/
harfbuzz.rs

1use skia_bindings as sb;
2
3use super::ScriptRunIterator;
4use crate::{prelude::*, Borrows, FontMgr, FourByteTag, Shaper};
5
6pub fn shaper_driven_wrapper(fallback_font_mgr: impl Into<Option<FontMgr>>) -> Option<Shaper> {
7    #[cfg(feature = "embed-icudtl")]
8    crate::icu::init();
9
10    Shaper::from_ptr(unsafe {
11        sb::C_SkShapers_HB_ShaperDrivenWrapper(fallback_font_mgr.into().into_ptr_or_null())
12    })
13}
14
15pub fn shape_then_wrap(fallback_font_mgr: impl Into<Option<FontMgr>>) -> Option<Shaper> {
16    #[cfg(feature = "embed-icudtl")]
17    crate::icu::init();
18
19    Shaper::from_ptr(unsafe {
20        sb::C_SkShapers_HB_ShapeThenWrap(fallback_font_mgr.into().into_ptr_or_null())
21    })
22}
23
24pub fn shape_dont_wrap_or_reorder(fallback_font_mgr: impl Into<Option<FontMgr>>) -> Option<Shaper> {
25    #[cfg(feature = "embed-icudtl")]
26    crate::icu::init();
27
28    Shaper::from_ptr(unsafe {
29        sb::C_SkShapers_HB_ShapeDontWrapOrReorder(fallback_font_mgr.into().into_ptr_or_null())
30    })
31}
32
33pub fn script_run_iterator(
34    utf8: &str,
35    script: impl Into<Option<FourByteTag>>,
36) -> Borrows<ScriptRunIterator> {
37    let script = script.into();
38    if let Some(tag) = script {
39        Shaper::new_script_run_iterator(utf8, tag)
40    } else {
41        Shaper::new_hb_icu_script_run_iterator(utf8)
42    }
43}