1 | use crate::{prelude::*, Typeface}; |
2 | use skia_bindings::{self as sb, skia_textlayout_FontArguments}; |
3 | use std::{fmt, hash}; |
4 | |
5 | pub type FontArguments = Handle<skia_textlayout_FontArguments>; |
6 | unsafe_send_sync!(FontArguments); |
7 | |
8 | impl 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 | |
16 | impl 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 | |
22 | impl NativeDrop for skia_textlayout_FontArguments { |
23 | fn drop(&mut self) { |
24 | unsafe { sb::C_FontArguments_destruct(self) } |
25 | } |
26 | } |
27 | |
28 | impl NativePartialEq for skia_textlayout_FontArguments { |
29 | fn eq(&self, rhs: &Self) -> bool { |
30 | unsafe { sb::C_FontArguments_Equals(self, rhs) } |
31 | } |
32 | } |
33 | |
34 | impl 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 | |
40 | impl fmt::Debug for FontArguments { |
41 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
42 | f.debug_struct(name:"FontArguments" ).finish() |
43 | } |
44 | } |
45 | |
46 | impl 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 | |