| 1 | use skia_bindings as sb; |
| 2 | |
| 3 | use super::ScriptRunIterator; |
| 4 | use crate::{prelude::*, Borrows, FontMgr, FourByteTag, Shaper}; |
| 5 | |
| 6 | pub 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(fontMgr:fallback_font_mgr.into().into_ptr_or_null()) |
| 12 | }) |
| 13 | } |
| 14 | |
| 15 | pub 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(fontMgr:fallback_font_mgr.into().into_ptr_or_null()) |
| 21 | }) |
| 22 | } |
| 23 | |
| 24 | pub 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(fontMgr:fallback_font_mgr.into().into_ptr_or_null()) |
| 30 | }) |
| 31 | } |
| 32 | |
| 33 | pub fn script_run_iterator( |
| 34 | utf8: &str, |
| 35 | script: impl Into<Option<FourByteTag>>, |
| 36 | ) -> Borrows<ScriptRunIterator> { |
| 37 | let script: Option = script.into(); |
| 38 | if let Some(tag: FourByteTag) = script { |
| 39 | Shaper::new_script_run_iterator(utf8, script:tag) |
| 40 | } else { |
| 41 | Shaper::new_hb_icu_script_run_iterator(utf8) |
| 42 | } |
| 43 | } |
| 44 | |