1use crate::{prelude::*, Typeface};
2use skia_bindings::{self as sb, skia_textlayout_FontArguments};
3use std::{fmt, hash};
4
5pub type FontArguments = Handle<skia_textlayout_FontArguments>;
6unsafe_send_sync!(FontArguments);
7
8impl From<crate::FontArguments<'_, '_>> for FontArguments {
9 fn from(fa: crate::FontArguments<'_, '_>) -> Self {
10 FontArguments::construct(|uninitialized: *mut skia_textlayout_FontArguments| unsafe {
11 sb::C_FontArguments_Construct(fontArguments:fa.native(), uninitialized)
12 })
13 }
14}
15
16impl NativeClone for skia_textlayout_FontArguments {
17 fn clone(&self) -> Self {
18 unsafe { construct(|fa: *mut skia_textlayout_FontArguments| sb::C_FontArguments_CopyConstruct(uninitialized:fa, self)) }
19 }
20}
21
22impl NativeDrop for skia_textlayout_FontArguments {
23 fn drop(&mut self) {
24 unsafe { sb::C_FontArguments_destruct(self) }
25 }
26}
27
28impl NativePartialEq for skia_textlayout_FontArguments {
29 fn eq(&self, rhs: &Self) -> bool {
30 unsafe { sb::C_FontArguments_Equals(self, rhs) }
31 }
32}
33
34impl NativeHash for skia_textlayout_FontArguments {
35 fn hash<H: hash::Hasher>(&self, state: &mut H) {
36 state.write_usize(unsafe { sb::C_FontArguments_hash(self) })
37 }
38}
39
40impl fmt::Debug for FontArguments {
41 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42 f.debug_struct(name:"FontArguments").finish()
43 }
44}
45
46impl FontArguments {
47 pub fn clone_typeface(&self, typeface: impl Into<Typeface>) -> Option<Typeface> {
48 Typeface::from_ptr(unsafe {
49 sb::C_FontArguments_cloneTypeface(self.native(), tf:typeface.into().into_ptr())
50 })
51 }
52}
53