objc2_ui_kit/generated/
UIFont.rs1use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-core-foundation")]
6use objc2_core_foundation::*;
7#[cfg(feature = "objc2-core-text")]
8use objc2_core_text::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13extern_class!(
14 #[unsafe(super(NSObject))]
16 #[derive(Debug, PartialEq, Eq, Hash)]
17 pub struct UIFont;
18);
19
20unsafe impl Send for UIFont {}
21
22unsafe impl Sync for UIFont {}
23
24#[cfg(feature = "objc2-core-text")]
25impl AsRef<UIFont> for CTFont {
26 #[inline]
27 fn as_ref(&self) -> &UIFont {
28 unsafe { &*((self as *const Self).cast()) }
29 }
30}
31
32#[cfg(feature = "objc2-core-text")]
33impl AsRef<CTFont> for UIFont {
34 #[inline]
35 fn as_ref(&self) -> &CTFont {
36 unsafe { &*((self as *const Self).cast()) }
37 }
38}
39
40extern_conformance!(
41 unsafe impl NSCoding for UIFont {}
42);
43
44extern_conformance!(
45 unsafe impl NSCopying for UIFont {}
46);
47
48unsafe impl CopyingHelper for UIFont {
49 type Result = Self;
50}
51
52extern_conformance!(
53 unsafe impl NSObjectProtocol for UIFont {}
54);
55
56extern_conformance!(
57 unsafe impl NSSecureCoding for UIFont {}
58);
59
60impl UIFont {
61 extern_methods!(
62 #[cfg(feature = "UIFontDescriptor")]
63 #[unsafe(method(preferredFontForTextStyle:))]
64 #[unsafe(method_family = none)]
65 pub fn preferredFontForTextStyle(style: &UIFontTextStyle) -> Retained<UIFont>;
66
67 #[cfg(all(feature = "UIFontDescriptor", feature = "UITraitCollection"))]
68 #[unsafe(method(preferredFontForTextStyle:compatibleWithTraitCollection:))]
69 #[unsafe(method_family = none)]
70 pub fn preferredFontForTextStyle_compatibleWithTraitCollection(
71 style: &UIFontTextStyle,
72 trait_collection: Option<&UITraitCollection>,
73 ) -> Retained<UIFont>;
74
75 #[cfg(feature = "objc2-core-foundation")]
76 #[unsafe(method(fontWithName:size:))]
77 #[unsafe(method_family = none)]
78 pub fn fontWithName_size(
79 font_name: &NSString,
80 font_size: CGFloat,
81 ) -> Option<Retained<UIFont>>;
82
83 #[unsafe(method(familyNames))]
84 #[unsafe(method_family = none)]
85 pub fn familyNames() -> Retained<NSArray<NSString>>;
86
87 #[unsafe(method(fontNamesForFamilyName:))]
88 #[unsafe(method_family = none)]
89 pub fn fontNamesForFamilyName(family_name: &NSString) -> Retained<NSArray<NSString>>;
90
91 #[cfg(feature = "objc2-core-foundation")]
92 #[unsafe(method(systemFontOfSize:))]
93 #[unsafe(method_family = none)]
94 pub fn systemFontOfSize(font_size: CGFloat) -> Retained<UIFont>;
95
96 #[cfg(feature = "objc2-core-foundation")]
97 #[unsafe(method(boldSystemFontOfSize:))]
98 #[unsafe(method_family = none)]
99 pub fn boldSystemFontOfSize(font_size: CGFloat) -> Retained<UIFont>;
100
101 #[cfg(feature = "objc2-core-foundation")]
102 #[unsafe(method(italicSystemFontOfSize:))]
103 #[unsafe(method_family = none)]
104 pub fn italicSystemFontOfSize(font_size: CGFloat) -> Retained<UIFont>;
105
106 #[cfg(all(feature = "UIFontDescriptor", feature = "objc2-core-foundation"))]
107 #[unsafe(method(systemFontOfSize:weight:))]
108 #[unsafe(method_family = none)]
109 pub fn systemFontOfSize_weight(
110 font_size: CGFloat,
111 weight: UIFontWeight,
112 ) -> Retained<UIFont>;
113
114 #[cfg(all(feature = "UIFontDescriptor", feature = "objc2-core-foundation"))]
115 #[unsafe(method(monospacedDigitSystemFontOfSize:weight:))]
116 #[unsafe(method_family = none)]
117 pub fn monospacedDigitSystemFontOfSize_weight(
118 font_size: CGFloat,
119 weight: UIFontWeight,
120 ) -> Retained<UIFont>;
121
122 #[cfg(all(feature = "UIFontDescriptor", feature = "objc2-core-foundation"))]
123 #[unsafe(method(systemFontOfSize:weight:width:))]
124 #[unsafe(method_family = none)]
125 pub fn systemFontOfSize_weight_width(
126 font_size: CGFloat,
127 weight: UIFontWeight,
128 width: UIFontWidth,
129 ) -> Retained<UIFont>;
130
131 #[cfg(all(feature = "UIFontDescriptor", feature = "objc2-core-foundation"))]
132 #[unsafe(method(monospacedSystemFontOfSize:weight:))]
133 #[unsafe(method_family = none)]
134 pub fn monospacedSystemFontOfSize_weight(
135 font_size: CGFloat,
136 weight: UIFontWeight,
137 ) -> Retained<UIFont>;
138
139 #[unsafe(method(familyName))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn familyName(&self) -> Retained<NSString>;
147
148 #[unsafe(method(fontName))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn fontName(&self) -> Retained<NSString>;
156
157 #[cfg(feature = "objc2-core-foundation")]
158 #[unsafe(method(pointSize))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn pointSize(&self) -> CGFloat;
166
167 #[cfg(feature = "objc2-core-foundation")]
168 #[unsafe(method(ascender))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn ascender(&self) -> CGFloat;
176
177 #[cfg(feature = "objc2-core-foundation")]
178 #[unsafe(method(descender))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn descender(&self) -> CGFloat;
186
187 #[cfg(feature = "objc2-core-foundation")]
188 #[unsafe(method(capHeight))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn capHeight(&self) -> CGFloat;
196
197 #[cfg(feature = "objc2-core-foundation")]
198 #[unsafe(method(xHeight))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn xHeight(&self) -> CGFloat;
206
207 #[cfg(feature = "objc2-core-foundation")]
208 #[unsafe(method(lineHeight))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn lineHeight(&self) -> CGFloat;
216
217 #[cfg(feature = "objc2-core-foundation")]
218 #[unsafe(method(leading))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn leading(&self) -> CGFloat;
226
227 #[cfg(feature = "objc2-core-foundation")]
228 #[unsafe(method(fontWithSize:))]
229 #[unsafe(method_family = none)]
230 pub fn fontWithSize(&self, font_size: CGFloat) -> Retained<UIFont>;
231
232 #[cfg(all(feature = "UIFontDescriptor", feature = "objc2-core-foundation"))]
233 #[unsafe(method(fontWithDescriptor:size:))]
234 #[unsafe(method_family = none)]
235 pub fn fontWithDescriptor_size(
236 descriptor: &UIFontDescriptor,
237 point_size: CGFloat,
238 ) -> Retained<UIFont>;
239
240 #[cfg(feature = "UIFontDescriptor")]
241 #[unsafe(method(fontDescriptor))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn fontDescriptor(&self) -> Retained<UIFontDescriptor>;
249 );
250}
251
252impl UIFont {
254 extern_methods!(
255 #[unsafe(method(init))]
256 #[unsafe(method_family = init)]
257 pub fn init(this: Allocated<Self>) -> Retained<Self>;
258
259 #[unsafe(method(new))]
260 #[unsafe(method_family = new)]
261 pub fn new() -> Retained<Self>;
262 );
263}
264
265impl DefaultRetained for UIFont {
266 #[inline]
267 fn default_retained() -> Retained<Self> {
268 Self::new()
269 }
270}