objc2_ui_kit/generated/
UIFontDescriptor.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
13#[repr(transparent)]
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17pub struct UIFontDescriptorSymbolicTraits(pub u32);
18bitflags::bitflags! {
19 impl UIFontDescriptorSymbolicTraits: u32 {
20 #[doc(alias = "UIFontDescriptorTraitItalic")]
21 const TraitItalic = 1<<0;
22 #[doc(alias = "UIFontDescriptorTraitBold")]
23 const TraitBold = 1<<1;
24 #[doc(alias = "UIFontDescriptorTraitExpanded")]
25 const TraitExpanded = 1<<5;
26 #[doc(alias = "UIFontDescriptorTraitCondensed")]
27 const TraitCondensed = 1<<6;
28 #[doc(alias = "UIFontDescriptorTraitMonoSpace")]
29 const TraitMonoSpace = 1<<10;
30 #[doc(alias = "UIFontDescriptorTraitVertical")]
31 const TraitVertical = 1<<11;
32 #[doc(alias = "UIFontDescriptorTraitUIOptimized")]
33 const TraitUIOptimized = 1<<12;
34 #[doc(alias = "UIFontDescriptorTraitTightLeading")]
35 const TraitTightLeading = 1<<15;
36 #[doc(alias = "UIFontDescriptorTraitLooseLeading")]
37 const TraitLooseLeading = 1<<16;
38 #[doc(alias = "UIFontDescriptorClassMask")]
39 const ClassMask = 0xF0000000;
40 #[doc(alias = "UIFontDescriptorClassUnknown")]
41 const ClassUnknown = 0<<28;
42 #[doc(alias = "UIFontDescriptorClassOldStyleSerifs")]
43 const ClassOldStyleSerifs = 1<<28;
44 #[doc(alias = "UIFontDescriptorClassTransitionalSerifs")]
45 const ClassTransitionalSerifs = 2<<28;
46 #[doc(alias = "UIFontDescriptorClassModernSerifs")]
47 const ClassModernSerifs = 3<<28;
48 #[doc(alias = "UIFontDescriptorClassClarendonSerifs")]
49 const ClassClarendonSerifs = 4<<28;
50 #[doc(alias = "UIFontDescriptorClassSlabSerifs")]
51 const ClassSlabSerifs = 5<<28;
52 #[doc(alias = "UIFontDescriptorClassFreeformSerifs")]
53 const ClassFreeformSerifs = 7<<28;
54 #[doc(alias = "UIFontDescriptorClassSansSerif")]
55 const ClassSansSerif = 8<<28;
56 #[doc(alias = "UIFontDescriptorClassOrnamentals")]
57 const ClassOrnamentals = 9<<28;
58 #[doc(alias = "UIFontDescriptorClassScripts")]
59 const ClassScripts = 10<<28;
60 #[doc(alias = "UIFontDescriptorClassSymbolic")]
61 const ClassSymbolic = 12<<28;
62 }
63}
64
65unsafe impl Encode for UIFontDescriptorSymbolicTraits {
66 const ENCODING: Encoding = u32::ENCODING;
67}
68
69unsafe impl RefEncode for UIFontDescriptorSymbolicTraits {
70 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
71}
72
73pub type UIFontDescriptorClass = NSUInteger;
75
76pub type UIFontTextStyle = NSString;
79
80pub type UIFontDescriptorAttributeName = NSString;
83
84pub type UIFontDescriptorTraitKey = NSString;
87
88pub type UIFontDescriptorFeatureKey = NSString;
91
92#[cfg(feature = "objc2-core-foundation")]
95pub type UIFontWeight = CGFloat;
96
97#[cfg(feature = "objc2-core-foundation")]
100pub type UIFontWidth = CGFloat;
101
102pub type UIFontDescriptorSystemDesign = NSString;
105
106extern "C" {
107 pub static UIFontDescriptorSystemDesignDefault: &'static UIFontDescriptorSystemDesign;
109}
110
111extern "C" {
112 pub static UIFontDescriptorSystemDesignRounded: &'static UIFontDescriptorSystemDesign;
114}
115
116extern "C" {
117 pub static UIFontDescriptorSystemDesignSerif: &'static UIFontDescriptorSystemDesign;
119}
120
121extern "C" {
122 pub static UIFontDescriptorSystemDesignMonospaced: &'static UIFontDescriptorSystemDesign;
124}
125
126extern_class!(
127 #[unsafe(super(NSObject))]
129 #[derive(Debug, PartialEq, Eq, Hash)]
130 pub struct UIFontDescriptor;
131);
132
133unsafe impl Send for UIFontDescriptor {}
134
135unsafe impl Sync for UIFontDescriptor {}
136
137#[cfg(feature = "objc2-core-text")]
138impl AsRef<UIFontDescriptor> for CTFontDescriptor {
139 #[inline]
140 fn as_ref(&self) -> &UIFontDescriptor {
141 unsafe { &*((self as *const Self).cast()) }
142 }
143}
144
145#[cfg(feature = "objc2-core-text")]
146impl AsRef<CTFontDescriptor> for UIFontDescriptor {
147 #[inline]
148 fn as_ref(&self) -> &CTFontDescriptor {
149 unsafe { &*((self as *const Self).cast()) }
150 }
151}
152
153extern_conformance!(
154 unsafe impl NSCoding for UIFontDescriptor {}
155);
156
157extern_conformance!(
158 unsafe impl NSCopying for UIFontDescriptor {}
159);
160
161unsafe impl CopyingHelper for UIFontDescriptor {
162 type Result = Self;
163}
164
165extern_conformance!(
166 unsafe impl NSObjectProtocol for UIFontDescriptor {}
167);
168
169extern_conformance!(
170 unsafe impl NSSecureCoding for UIFontDescriptor {}
171);
172
173impl UIFontDescriptor {
174 extern_methods!(
175 #[unsafe(method(init))]
176 #[unsafe(method_family = init)]
177 pub fn init(this: Allocated<Self>) -> Retained<Self>;
178
179 #[unsafe(method(initWithCoder:))]
183 #[unsafe(method_family = init)]
184 pub unsafe fn initWithCoder(
185 this: Allocated<Self>,
186 coder: &NSCoder,
187 ) -> Option<Retained<Self>>;
188
189 #[unsafe(method(postscriptName))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn postscriptName(&self) -> Retained<NSString>;
197
198 #[cfg(feature = "objc2-core-foundation")]
199 #[unsafe(method(pointSize))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn pointSize(&self) -> CGFloat;
207
208 #[cfg(feature = "objc2-core-foundation")]
209 #[unsafe(method(matrix))]
215 #[unsafe(method_family = none)]
216 pub unsafe fn matrix(&self) -> CGAffineTransform;
217
218 #[unsafe(method(symbolicTraits))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn symbolicTraits(&self) -> UIFontDescriptorSymbolicTraits;
226
227 #[unsafe(method(objectForKey:))]
228 #[unsafe(method_family = none)]
229 pub fn objectForKey(
230 &self,
231 an_attribute: &UIFontDescriptorAttributeName,
232 ) -> Option<Retained<AnyObject>>;
233
234 #[unsafe(method(fontAttributes))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn fontAttributes(
242 &self,
243 ) -> Retained<NSDictionary<UIFontDescriptorAttributeName, AnyObject>>;
244
245 #[unsafe(method(matchingFontDescriptorsWithMandatoryKeys:))]
246 #[unsafe(method_family = none)]
247 pub fn matchingFontDescriptorsWithMandatoryKeys(
248 &self,
249 mandatory_keys: Option<&NSSet<UIFontDescriptorAttributeName>>,
250 ) -> Retained<NSArray<UIFontDescriptor>>;
251
252 #[unsafe(method(fontDescriptorWithFontAttributes:))]
256 #[unsafe(method_family = none)]
257 pub unsafe fn fontDescriptorWithFontAttributes(
258 attributes: &NSDictionary<UIFontDescriptorAttributeName, AnyObject>,
259 ) -> Retained<UIFontDescriptor>;
260
261 #[cfg(feature = "objc2-core-foundation")]
262 #[unsafe(method(fontDescriptorWithName:size:))]
263 #[unsafe(method_family = none)]
264 pub fn fontDescriptorWithName_size(
265 font_name: &NSString,
266 size: CGFloat,
267 ) -> Retained<UIFontDescriptor>;
268
269 #[cfg(feature = "objc2-core-foundation")]
270 #[unsafe(method(fontDescriptorWithName:matrix:))]
271 #[unsafe(method_family = none)]
272 pub fn fontDescriptorWithName_matrix(
273 font_name: &NSString,
274 matrix: CGAffineTransform,
275 ) -> Retained<UIFontDescriptor>;
276
277 #[unsafe(method(preferredFontDescriptorWithTextStyle:))]
278 #[unsafe(method_family = none)]
279 pub fn preferredFontDescriptorWithTextStyle(
280 style: &UIFontTextStyle,
281 ) -> Retained<UIFontDescriptor>;
282
283 #[cfg(feature = "UITraitCollection")]
284 #[unsafe(method(preferredFontDescriptorWithTextStyle:compatibleWithTraitCollection:))]
285 #[unsafe(method_family = none)]
286 pub fn preferredFontDescriptorWithTextStyle_compatibleWithTraitCollection(
287 style: &UIFontTextStyle,
288 trait_collection: Option<&UITraitCollection>,
289 ) -> Retained<UIFontDescriptor>;
290
291 #[unsafe(method(initWithFontAttributes:))]
295 #[unsafe(method_family = init)]
296 pub unsafe fn initWithFontAttributes(
297 this: Allocated<Self>,
298 attributes: &NSDictionary<UIFontDescriptorAttributeName, AnyObject>,
299 ) -> Retained<Self>;
300
301 #[unsafe(method(fontDescriptorByAddingAttributes:))]
305 #[unsafe(method_family = none)]
306 pub unsafe fn fontDescriptorByAddingAttributes(
307 &self,
308 attributes: &NSDictionary<UIFontDescriptorAttributeName, AnyObject>,
309 ) -> Retained<UIFontDescriptor>;
310
311 #[cfg(feature = "objc2-core-foundation")]
312 #[unsafe(method(fontDescriptorWithSize:))]
313 #[unsafe(method_family = none)]
314 pub fn fontDescriptorWithSize(&self, new_point_size: CGFloat)
315 -> Retained<UIFontDescriptor>;
316
317 #[cfg(feature = "objc2-core-foundation")]
318 #[unsafe(method(fontDescriptorWithMatrix:))]
319 #[unsafe(method_family = none)]
320 pub fn fontDescriptorWithMatrix(
321 &self,
322 matrix: CGAffineTransform,
323 ) -> Retained<UIFontDescriptor>;
324
325 #[unsafe(method(fontDescriptorWithFace:))]
326 #[unsafe(method_family = none)]
327 pub fn fontDescriptorWithFace(&self, new_face: &NSString) -> Retained<UIFontDescriptor>;
328
329 #[unsafe(method(fontDescriptorWithFamily:))]
330 #[unsafe(method_family = none)]
331 pub fn fontDescriptorWithFamily(&self, new_family: &NSString)
332 -> Retained<UIFontDescriptor>;
333
334 #[unsafe(method(fontDescriptorWithSymbolicTraits:))]
335 #[unsafe(method_family = none)]
336 pub fn fontDescriptorWithSymbolicTraits(
337 &self,
338 symbolic_traits: UIFontDescriptorSymbolicTraits,
339 ) -> Option<Retained<UIFontDescriptor>>;
340
341 #[unsafe(method(fontDescriptorWithDesign:))]
342 #[unsafe(method_family = none)]
343 pub fn fontDescriptorWithDesign(
344 &self,
345 design: &UIFontDescriptorSystemDesign,
346 ) -> Option<Retained<UIFontDescriptor>>;
347 );
348}
349
350impl UIFontDescriptor {
352 extern_methods!(
353 #[unsafe(method(new))]
354 #[unsafe(method_family = new)]
355 pub fn new() -> Retained<Self>;
356 );
357}
358
359impl DefaultRetained for UIFontDescriptor {
360 #[inline]
361 fn default_retained() -> Retained<Self> {
362 Self::new()
363 }
364}
365
366extern "C" {
367 pub static UIFontDescriptorFamilyAttribute: &'static UIFontDescriptorAttributeName;
369}
370
371extern "C" {
372 pub static UIFontDescriptorNameAttribute: &'static UIFontDescriptorAttributeName;
374}
375
376extern "C" {
377 pub static UIFontDescriptorFaceAttribute: &'static UIFontDescriptorAttributeName;
379}
380
381extern "C" {
382 pub static UIFontDescriptorSizeAttribute: &'static UIFontDescriptorAttributeName;
384}
385
386extern "C" {
387 pub static UIFontDescriptorVisibleNameAttribute: &'static UIFontDescriptorAttributeName;
389}
390
391extern "C" {
392 pub static UIFontDescriptorMatrixAttribute: &'static UIFontDescriptorAttributeName;
394}
395
396extern "C" {
397 pub static UIFontDescriptorCharacterSetAttribute: &'static UIFontDescriptorAttributeName;
399}
400
401extern "C" {
402 pub static UIFontDescriptorCascadeListAttribute: &'static UIFontDescriptorAttributeName;
404}
405
406extern "C" {
407 pub static UIFontDescriptorTraitsAttribute: &'static UIFontDescriptorAttributeName;
409}
410
411extern "C" {
412 pub static UIFontDescriptorFixedAdvanceAttribute: &'static UIFontDescriptorAttributeName;
414}
415
416extern "C" {
417 pub static UIFontDescriptorFeatureSettingsAttribute: &'static UIFontDescriptorAttributeName;
419}
420
421extern "C" {
422 pub static UIFontDescriptorTextStyleAttribute: &'static UIFontDescriptorAttributeName;
424}
425
426extern "C" {
427 pub static UIFontSymbolicTrait: &'static UIFontDescriptorTraitKey;
429}
430
431extern "C" {
432 pub static UIFontWeightTrait: &'static UIFontDescriptorTraitKey;
434}
435
436extern "C" {
437 pub static UIFontWidthTrait: &'static UIFontDescriptorTraitKey;
439}
440
441extern "C" {
442 pub static UIFontSlantTrait: &'static UIFontDescriptorTraitKey;
444}
445
446extern "C" {
447 #[cfg(feature = "objc2-core-foundation")]
449 pub static UIFontWeightUltraLight: UIFontWeight;
450}
451
452extern "C" {
453 #[cfg(feature = "objc2-core-foundation")]
455 pub static UIFontWeightThin: UIFontWeight;
456}
457
458extern "C" {
459 #[cfg(feature = "objc2-core-foundation")]
461 pub static UIFontWeightLight: UIFontWeight;
462}
463
464extern "C" {
465 #[cfg(feature = "objc2-core-foundation")]
467 pub static UIFontWeightRegular: UIFontWeight;
468}
469
470extern "C" {
471 #[cfg(feature = "objc2-core-foundation")]
473 pub static UIFontWeightMedium: UIFontWeight;
474}
475
476extern "C" {
477 #[cfg(feature = "objc2-core-foundation")]
479 pub static UIFontWeightSemibold: UIFontWeight;
480}
481
482extern "C" {
483 #[cfg(feature = "objc2-core-foundation")]
485 pub static UIFontWeightBold: UIFontWeight;
486}
487
488extern "C" {
489 #[cfg(feature = "objc2-core-foundation")]
491 pub static UIFontWeightHeavy: UIFontWeight;
492}
493
494extern "C" {
495 #[cfg(feature = "objc2-core-foundation")]
497 pub static UIFontWeightBlack: UIFontWeight;
498}
499
500extern "C" {
501 #[cfg(feature = "objc2-core-foundation")]
503 pub static UIFontWidthCondensed: UIFontWidth;
504}
505
506extern "C" {
507 #[cfg(feature = "objc2-core-foundation")]
509 pub static UIFontWidthStandard: UIFontWidth;
510}
511
512extern "C" {
513 #[cfg(feature = "objc2-core-foundation")]
515 pub static UIFontWidthExpanded: UIFontWidth;
516}
517
518extern "C" {
519 #[cfg(feature = "objc2-core-foundation")]
521 pub static UIFontWidthCompressed: UIFontWidth;
522}
523
524extern "C" {
525 pub static UIFontFeatureTypeIdentifierKey: &'static UIFontDescriptorFeatureKey;
527}
528
529extern "C" {
530 pub static UIFontFeatureSelectorIdentifierKey: &'static UIFontDescriptorFeatureKey;
532}
533
534extern "C" {
535 pub static UIFontTextStyleLargeTitle: &'static UIFontTextStyle;
537}
538
539extern "C" {
540 pub static UIFontTextStyleExtraLargeTitle: &'static UIFontTextStyle;
542}
543
544extern "C" {
545 pub static UIFontTextStyleExtraLargeTitle2: &'static UIFontTextStyle;
547}
548
549extern "C" {
550 pub static UIFontTextStyleTitle1: &'static UIFontTextStyle;
552}
553
554extern "C" {
555 pub static UIFontTextStyleTitle2: &'static UIFontTextStyle;
557}
558
559extern "C" {
560 pub static UIFontTextStyleTitle3: &'static UIFontTextStyle;
562}
563
564extern "C" {
565 pub static UIFontTextStyleHeadline: &'static UIFontTextStyle;
567}
568
569extern "C" {
570 pub static UIFontTextStyleSubheadline: &'static UIFontTextStyle;
572}
573
574extern "C" {
575 pub static UIFontTextStyleBody: &'static UIFontTextStyle;
577}
578
579extern "C" {
580 pub static UIFontTextStyleCallout: &'static UIFontTextStyle;
582}
583
584extern "C" {
585 pub static UIFontTextStyleFootnote: &'static UIFontTextStyle;
587}
588
589extern "C" {
590 pub static UIFontTextStyleCaption1: &'static UIFontTextStyle;
592}
593
594extern "C" {
595 pub static UIFontTextStyleCaption2: &'static UIFontTextStyle;
597}