objc2-core-text 0.3.2

Bindings to the CoreText framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontdescriptor?language=objc)
///
/// This is toll-free bridged with `NSFontDescriptor`.
#[doc(alias = "CTFontDescriptorRef")]
#[repr(C)]
pub struct CTFontDescriptor {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

cf_type!(
    unsafe impl CTFontDescriptor {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
    unsafe impl RefEncode<"__CTFontDescriptor"> for CTFontDescriptor {}
);

unsafe impl ConcreteType for CTFontDescriptor {
    /// Returns the type identifier for Core Text font descriptor
    /// references.
    ///
    /// Returns: The identifier for the opaque type CTFontDescriptorRef.
    #[doc(alias = "CTFontDescriptorGetTypeID")]
    #[inline]
    fn type_id() -> CFTypeID {
        extern "C-unwind" {
            fn CTFontDescriptorGetTypeID() -> CFTypeID;
        }
        unsafe { CTFontDescriptorGetTypeID() }
    }
}

extern "C" {
    /// kCTFontURLAttribute
    ///
    /// The font URL.
    ///
    /// This is the key for accessing the font URL from the font descriptor. The value associated with this key is a CFURLRef.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonturlattribute?language=objc)
    pub static kCTFontURLAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontNameAttribute
    ///
    /// The PostScript name.
    ///
    /// This is the key for retrieving the PostScript name from the font descriptor. When matching, this is treated more generically: the system first tries to find fonts with this PostScript name. If none is found, the system tries to find fonts with this family name, and, finally, if still nothing, tries to find fonts with this display name. The value associated with this key is a CFStringRef. If unspecified, defaults to "Helvetica", if unavailable falls back to global font cascade list.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontnameattribute?language=objc)
    pub static kCTFontNameAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontDisplayNameAttribute
    ///
    /// The display name.
    ///
    /// This is the key for accessing the name used to display the font. Most commonly this is the full name. The value associated with this key is a CFStringRef.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdisplaynameattribute?language=objc)
    pub static kCTFontDisplayNameAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontFamilyNameAttribute
    ///
    /// The family name.
    ///
    /// This is the key for accessing the family name from the font descriptor. The value associated with this key is a CFStringRef.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfamilynameattribute?language=objc)
    pub static kCTFontFamilyNameAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontStyleNameAttribute
    ///
    /// The style name.
    ///
    /// This is the key for accessing the style name of the font. This name represents the designer's description of the font's style. The value associated with this key is a CFStringRef.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontstylenameattribute?language=objc)
    pub static kCTFontStyleNameAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontTraitsAttribute
    ///
    /// The font traits dictionary.
    ///
    /// This is the key for accessing the dictionary of font traits for stylistic information. See CTFontTraits.h for the list of font traits. The value associated with this key is a CFDictionaryRef.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttraitsattribute?language=objc)
    pub static kCTFontTraitsAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontVariationAttribute
    ///
    /// The font variation dictionary.
    ///
    /// This key is used to obtain the font variation instance as a CFDictionaryRef. If specified in a font descriptor, fonts with the specified axes will be primary match candidates, if no such fonts exist, this attribute will be ignored.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationattribute?language=objc)
    pub static kCTFontVariationAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontVariationAxesAttribute
    ///
    /// An array of variation axis dictionaries or null if the font does not support variations. Each variation axis dictionary contains the five kCTFontVariationAxis-prefixed keys.
    /// Unlike the result of CTFontCopyVariationAxes(), kCTFontVariationAxisNameKey values for this attribute are not localized.
    /// Before macOS 13.0 and iOS 16.0 this attribute is not accurate and CTFontCopyVariationAxes() should be used instead.
    ///
    ///
    /// See also: CTFontCopyVariationAxes
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationaxesattribute?language=objc)
    pub static kCTFontVariationAxesAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontSizeAttribute
    ///
    /// The font point size.
    ///
    /// This key is used to obtain or specify the font point size. Creating a font with this unspecified will default to a point size of 12.0. The value for this key is represented as a CFNumberRef.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontsizeattribute?language=objc)
    pub static kCTFontSizeAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontMatrixAttribute
    ///
    /// The font transformation matrix.
    ///
    /// This key is used to specify the font transformation matrix when creating a font. The default value is CGAffineTransformIdentity. The value for this key is a CFDataRef containing a CGAffineTransform, of which only the a, b, c, and d fields are used.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontmatrixattribute?language=objc)
    pub static kCTFontMatrixAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontCascadeListAttribute
    ///
    /// The font cascade list.
    ///
    /// This key is used to specify or obtain the cascade list used for a font reference. The cascade list is a CFArrayRef containing CTFontDescriptorRefs. If unspecified, the global cascade list is used. This list is not consulted for private-use characters on OS X 10.10, iOS 8, or earlier.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontcascadelistattribute?language=objc)
    pub static kCTFontCascadeListAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontCharacterSetAttribute
    ///
    /// The font Unicode character coverage set.
    ///
    /// The value for this key is a CFCharacterSetRef. Creating a font with this attribute will restrict the font to a subset of its actual character set.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontcharactersetattribute?language=objc)
    pub static kCTFontCharacterSetAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontLanguagesAttribute
    ///
    /// The list of supported languages.
    ///
    /// The value for this key is a CFArrayRef of CFStringRef language identifiers conforming to UTS #35. It can be requested from any font. If present in a descriptor used for matching, only fonts supporting the specified languages will be returned.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontlanguagesattribute?language=objc)
    pub static kCTFontLanguagesAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontBaselineAdjustAttribute
    ///
    /// The baseline adjustment to apply to font metrics.
    ///
    /// The value for this key is a floating-point CFNumberRef. This is primarily used when defining font descriptors for a cascade list to keep the baseline of all fonts even.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontbaselineadjustattribute?language=objc)
    pub static kCTFontBaselineAdjustAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontMacintoshEncodingsAttribute
    ///
    /// The Macintosh encodings (legacy script codes).
    ///
    /// The value associated with this key is a CFNumberRef containing a bitfield of the script codes in
    /// <CoreText
    /// /SFNTTypes.h>; bit 0 corresponds to kFontRomanScript, and so on. This attribute is provided for legacy compatibility.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontmacintoshencodingsattribute?language=objc)
    pub static kCTFontMacintoshEncodingsAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontFeaturesAttribute
    ///
    /// The array of font features.
    ///
    /// This key is used to specify or obtain the font features for a font reference. The value associated with this key is a CFArrayRef of font feature dictionaries as documented for CTFontCopyFeatures() in
    /// <CoreText
    /// /CTFont.h>.
    /// Unlike the result of CTFontCopyFeatures(), this attribute does not contain localized names.
    ///
    ///
    /// See also: CTFontCopyFeatures
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturesattribute?language=objc)
    pub static kCTFontFeaturesAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontFeatureSettingsAttribute
    ///
    /// The array of typographic feature settings.
    ///
    /// This key is used to specify an array of zero or more feature settings. Each setting dictionary indicates which setting should be applied. In the case of duplicate or conflicting settings the last setting in the list will take precedence. In the case of AAT settings, it is the caller's responsibility to handle exclusive and non-exclusive settings as necessary.
    /// An AAT setting dictionary contains a tuple of a kCTFontFeatureTypeIdentifierKey key-value pair and a kCTFontFeatureSelectorIdentifierKey key-value pair.
    /// An OpenType setting dictionary contains a tuple of a kCTFontOpenTypeFeatureTag key-value pair and a kCTFontOpenTypeFeatureValue key-value pair.
    ///
    /// Starting with OS X 10.10 and iOS 8.0, settings are also accepted (but not returned) in the following simplified forms:
    /// An OpenType setting can be either an array pair of tag string and value number, or a tag string on its own. For example:
    /// @
    /// [
    /// "
    /// c2sc", @1 ] or simply @"c2sc". An unspecified value enables the feature and a value of zero disables it.
    /// An AAT setting can be specified as an array pair of type and selector numbers. For example:
    /// @
    /// [
    /// @
    /// (kUpperCaseType),
    /// @
    /// (kUpperCaseSmallCapsSelector) ].
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturesettingsattribute?language=objc)
    pub static kCTFontFeatureSettingsAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontFixedAdvanceAttribute
    ///
    /// Specifies advance width.
    ///
    /// This key is used to specify a constant advance width, which affects the glyph metrics of any font instance created with this key; it overrides font values and the font transformation matrix, if any. The value associated with this key must be a CFNumberRef.
    ///
    /// Starting with macOS 10.14 and iOS 12.0, this only affects glyph advances that have non-zero width when this attribute is not present.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfixedadvanceattribute?language=objc)
    pub static kCTFontFixedAdvanceAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontOrientationAttribute
    ///
    /// The orientation attribute.
    ///
    /// This key is used to specify a particular orientation for the glyphs of the font. The value associated with this key is a int as a CFNumberRef. If you want to receive vertical metrics from a font for vertical rendering, specify kCTFontVerticalOrientation. If unspecified, the font will use its native orientation.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontorientationattribute?language=objc)
    pub static kCTFontOrientationAttribute: &'static CFString;
}

/// Specifies the intended rendering orientation of the font for obtaining glyph metrics.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontorientation?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CTFontOrientation(pub u32);
impl CTFontOrientation {
    #[doc(alias = "kCTFontOrientationDefault")]
    pub const Default: Self = Self(0);
    #[doc(alias = "kCTFontOrientationHorizontal")]
    pub const Horizontal: Self = Self(1);
    #[doc(alias = "kCTFontOrientationVertical")]
    pub const Vertical: Self = Self(2);
    #[deprecated = "Deprecated"]
    pub const kCTFontDefaultOrientation: Self = Self(CTFontOrientation::Default.0);
    #[deprecated = "Deprecated"]
    pub const kCTFontHorizontalOrientation: Self = Self(CTFontOrientation::Horizontal.0);
    #[deprecated = "Deprecated"]
    pub const kCTFontVerticalOrientation: Self = Self(CTFontOrientation::Vertical.0);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CTFontOrientation {
    const ENCODING: Encoding = u32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTFontOrientation {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    /// kCTFontFormatAttribute
    ///
    /// Specifies the recognized format of the font.
    ///
    /// The attribute is used to specify or obtain the format of the font. The returned value is a CFNumber containing one of the constants defined below.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontformatattribute?language=objc)
    pub static kCTFontFormatAttribute: &'static CFString;
}

/// The font is not a recognized format
///
/// The font is an OpenType format containing PostScript data
///
/// The font is an OpenType format containing TrueType data
///
/// The font is a recognized TrueType format
///
/// The font is a recognized PostScript format
///
/// The font is a bitmap only format
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontformat?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CTFontFormat(pub u32);
impl CTFontFormat {
    #[doc(alias = "kCTFontFormatUnrecognized")]
    pub const Unrecognized: Self = Self(0);
    #[doc(alias = "kCTFontFormatOpenTypePostScript")]
    pub const OpenTypePostScript: Self = Self(1);
    #[doc(alias = "kCTFontFormatOpenTypeTrueType")]
    pub const OpenTypeTrueType: Self = Self(2);
    #[doc(alias = "kCTFontFormatTrueType")]
    pub const TrueType: Self = Self(3);
    #[doc(alias = "kCTFontFormatPostScript")]
    pub const PostScript: Self = Self(4);
    #[doc(alias = "kCTFontFormatBitmap")]
    pub const Bitmap: Self = Self(5);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CTFontFormat {
    const ENCODING: Encoding = u32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTFontFormat {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    /// kCTFontRegistrationScopeAttribute
    ///
    /// Specifies the font descriptor's registration scope.
    ///
    /// The attribute is used to specify or obtain the font registration scope. The value returned is a CFNumberRef containing one of the CTFontManagerScope enumerated values. A value of NULL can be returned for font descriptors that are not registered.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontregistrationscopeattribute?language=objc)
    pub static kCTFontRegistrationScopeAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontPriorityAttribute
    ///
    /// The font descriptors priority when resolving duplicates and sorting match results.
    ///
    /// This key is used to obtain or specify the font priority. The value returned is a CFNumberRef containing an integer value as defined below. The higher the value, the higher the priority of the font. Only registered fonts will have a priority. Unregistered font descriptors will return NULL.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpriorityattribute?language=objc)
    pub static kCTFontPriorityAttribute: &'static CFString;
}

/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritysystem?language=objc)
pub const kCTFontPrioritySystem: c_uint = 10000;
/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritynetwork?language=objc)
pub const kCTFontPriorityNetwork: c_uint = 20000;
/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritycomputer?language=objc)
pub const kCTFontPriorityComputer: c_uint = 30000;
/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpriorityuser?language=objc)
pub const kCTFontPriorityUser: c_uint = 40000;
/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritydynamic?language=objc)
pub const kCTFontPriorityDynamic: c_uint = 50000;
/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpriorityprocess?language=objc)
pub const kCTFontPriorityProcess: c_uint = 60000;

/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontpriority?language=objc)
pub type CTFontPriority = u32;

extern "C" {
    /// kCTFontEnabledAttribute
    ///
    /// The font enabled state.
    ///
    /// The value associated with this key is a CFBoolean. Unregistered font descriptors will return NULL, which is equivalent to false.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontenabledattribute?language=objc)
    pub static kCTFontEnabledAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontDownloadableAttribute
    ///
    /// The font downloadable state.
    ///
    /// The value associated with this key is a CFBoolean. If it is true, CoreText attempts to download a font if necessary when matching a descriptor.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdownloadableattribute?language=objc)
    pub static kCTFontDownloadableAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontDownloadedAttribute
    ///
    /// The download state.
    ///
    /// The value associated with this key is a CFBoolean. If it is true, corresponding FontAsset has been downloaded. (but still it may be necessary to call appropriate API in order to use the font in the FontAsset.)
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdownloadedattribute?language=objc)
    pub static kCTFontDownloadedAttribute: &'static CFString;
}

extern "C" {
    /// kCTFontOpticalSizeAttribute
    ///
    /// The point size at which this font is intended to be used.
    ///
    /// The value is a CFNumber used to activate size-specific (not linearly scaled) metrics. Starting with macOS 10.14 and iOS 12.0, the CFString "auto" can be used instead to request an optical size matching the point size. Starting with macOS 10.15 and iOS 13.0, the CFString "none" can be used instead to explicitly disable automatic optical sizing enabled by the font.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontopticalsizeattribute?language=objc)
    pub static kCTFontOpticalSizeAttribute: &'static CFString;
}

impl CTFontDescriptor {
    /// Creates a new font descriptor with the provided PostScript name and size.
    ///
    ///
    /// Parameter `name`: The PostScript name to be used for the font descriptor as a CFStringRef. Any font name beginning with a "." is reserved for the system and should not be used here.
    ///
    ///
    /// Parameter `size`: The point size. If 0.0, the kCTFontSizeAttribute will be omitted from the font descriptor.
    ///
    ///
    /// Returns: This function creates a new font descriptor reference with the given PostScript name and point size.
    ///
    ///
    /// If you are trying to create a system UI font descriptor (with name beginning with a "."), you should create a font with CTFontCreateUIFontForLanguage() or appropriate AppKit/UIKit APIs instead, then use CTFontCopyFontDescriptor() to get its font descriptor.
    #[doc(alias = "CTFontDescriptorCreateWithNameAndSize")]
    #[inline]
    pub unsafe fn with_name_and_size(
        name: &CFString,
        size: CGFloat,
    ) -> CFRetained<CTFontDescriptor> {
        extern "C-unwind" {
            fn CTFontDescriptorCreateWithNameAndSize(
                name: &CFString,
                size: CGFloat,
            ) -> Option<NonNull<CTFontDescriptor>>;
        }
        let ret = unsafe { CTFontDescriptorCreateWithNameAndSize(name, size) };
        let ret =
            ret.expect("function was marked as returning non-null, but actually returned NULL");
        unsafe { CFRetained::from_raw(ret) }
    }

    /// Creates a new font descriptor reference from a dictionary of attributes.
    ///
    ///
    /// Parameter `attributes`: A CFDictionaryRef of arbitrary attributes.
    ///
    ///
    /// Returns: This function creates a new font descriptor with the attributes specified. This dictionary can contain arbitrary attributes that will be preserved, however unrecognized attributes will be ignored on font creation and and may not be preserved over the round trip (descriptor -> font -> descriptor).
    ///
    /// # Safety
    ///
    /// `attributes` generics must be of the correct type.
    #[doc(alias = "CTFontDescriptorCreateWithAttributes")]
    #[inline]
    pub unsafe fn with_attributes(attributes: &CFDictionary) -> CFRetained<CTFontDescriptor> {
        extern "C-unwind" {
            fn CTFontDescriptorCreateWithAttributes(
                attributes: &CFDictionary,
            ) -> Option<NonNull<CTFontDescriptor>>;
        }
        let ret = unsafe { CTFontDescriptorCreateWithAttributes(attributes) };
        let ret =
            ret.expect("function was marked as returning non-null, but actually returned NULL");
        unsafe { CFRetained::from_raw(ret) }
    }

    /// Creates a copy of the original font descriptor with new attributes.
    ///
    ///
    /// Parameter `original`: The original font descriptor reference.
    ///
    ///
    /// Parameter `attributes`: A CFDictionaryRef of arbitrary attributes.
    ///
    ///
    /// Returns: This function creates a new copy of the original font descriptor with attributes augmented by those specified. If there are conflicts between attributes, the new attributes will replace existing ones, except for kCTFontVariationAttribute and kCTFontFeatureSettingsAttribute which will be merged.
    /// Starting with macOS 10.12 and iOS 10.0, setting the value of kCTFontFeatureSettingsAttribute to kCFNull will clear the feature settings of the original font descriptor. Setting the value of any individual feature settings pair in the kCTFontFeatureSettingsAttribute value array to kCFNull will clear that feature setting alone. For example, an element like
    /// @
    /// { (id)kCTFontFeatureTypeIdentifierKey:
    /// @
    /// (kLigaturesType), (id)kCTFontFeatureSelectorIdentifierKey: (id)kCFNull } means clear the kLigatureType feature set in the original font descriptor. An element like
    /// @
    /// [
    /// "
    /// liga", (id)kCFNull ] will have the same effect.
    ///
    ///
    /// See also: kCTFontFeatureSettingsAttribute
    ///
    /// # Safety
    ///
    /// `attributes` generics must be of the correct type.
    #[doc(alias = "CTFontDescriptorCreateCopyWithAttributes")]
    #[inline]
    pub unsafe fn copy_with_attributes(
        &self,
        attributes: &CFDictionary,
    ) -> CFRetained<CTFontDescriptor> {
        extern "C-unwind" {
            fn CTFontDescriptorCreateCopyWithAttributes(
                original: &CTFontDescriptor,
                attributes: &CFDictionary,
            ) -> Option<NonNull<CTFontDescriptor>>;
        }
        let ret = unsafe { CTFontDescriptorCreateCopyWithAttributes(self, attributes) };
        let ret =
            ret.expect("function was marked as returning non-null, but actually returned NULL");
        unsafe { CFRetained::from_raw(ret) }
    }

    /// Returns a new font descriptor in the specified family based on the traits of the original descriptor.
    ///
    ///
    /// Parameter `original`: The original font descriptor reference.
    ///
    ///
    /// Parameter `family`: The name of the desired family.
    ///
    ///
    /// Returns: Returns a new font reference with the original traits in the given family, or NULL if none found in the system.
    #[doc(alias = "CTFontDescriptorCreateCopyWithFamily")]
    #[inline]
    pub unsafe fn copy_with_family(
        &self,
        family: &CFString,
    ) -> Option<CFRetained<CTFontDescriptor>> {
        extern "C-unwind" {
            fn CTFontDescriptorCreateCopyWithFamily(
                original: &CTFontDescriptor,
                family: &CFString,
            ) -> Option<NonNull<CTFontDescriptor>>;
        }
        let ret = unsafe { CTFontDescriptorCreateCopyWithFamily(self, family) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Returns a new font descriptor based on the original descriptor having the specified symbolic traits.
    ///
    ///
    /// Parameter `original`: The original font descriptor reference.
    ///
    ///
    /// Parameter `symTraitValue`: The value of the symbolic traits. This bitfield is used to indicate the desired value for the traits specified by the symTraitMask parameter. Used in conjunction, they can allow for trait removal as well as addition.
    ///
    ///
    /// Parameter `symTraitMask`: The mask bits of the symbolic traits. This bitfield is used to indicate the traits that should be changed.
    ///
    ///
    /// Returns: Returns a new font descriptor reference in the same family with the given symbolic traits, or NULL if none found in the system.
    #[doc(alias = "CTFontDescriptorCreateCopyWithSymbolicTraits")]
    #[cfg(feature = "CTFontTraits")]
    #[inline]
    pub unsafe fn copy_with_symbolic_traits(
        &self,
        sym_trait_value: CTFontSymbolicTraits,
        sym_trait_mask: CTFontSymbolicTraits,
    ) -> Option<CFRetained<CTFontDescriptor>> {
        extern "C-unwind" {
            fn CTFontDescriptorCreateCopyWithSymbolicTraits(
                original: &CTFontDescriptor,
                sym_trait_value: CTFontSymbolicTraits,
                sym_trait_mask: CTFontSymbolicTraits,
            ) -> Option<NonNull<CTFontDescriptor>>;
        }
        let ret = unsafe {
            CTFontDescriptorCreateCopyWithSymbolicTraits(self, sym_trait_value, sym_trait_mask)
        };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Creates a copy of the original font descriptor with a new variation instance.
    ///
    ///
    /// Parameter `original`: The original font descriptor reference.
    ///
    ///
    /// Parameter `variationIdentifier`: The variation axis identifier. This is the four character code of the variation axis as a CFNumberRef.
    ///
    ///
    /// Parameter `variationValue`: The value corresponding with the variation instance.
    ///
    ///
    /// Returns: This function returns a copy of the original font descriptor with a new variation instance. This is a convenience method for easily creating new variation font instances.
    #[doc(alias = "CTFontDescriptorCreateCopyWithVariation")]
    #[inline]
    pub unsafe fn copy_with_variation(
        &self,
        variation_identifier: &CFNumber,
        variation_value: CGFloat,
    ) -> CFRetained<CTFontDescriptor> {
        extern "C-unwind" {
            fn CTFontDescriptorCreateCopyWithVariation(
                original: &CTFontDescriptor,
                variation_identifier: &CFNumber,
                variation_value: CGFloat,
            ) -> Option<NonNull<CTFontDescriptor>>;
        }
        let ret = unsafe {
            CTFontDescriptorCreateCopyWithVariation(self, variation_identifier, variation_value)
        };
        let ret =
            ret.expect("function was marked as returning non-null, but actually returned NULL");
        unsafe { CFRetained::from_raw(ret) }
    }

    /// Copies a font descriptor with new feature setting.
    ///
    ///
    /// This is a convenience method to more easily toggle the state of individual features.
    ///
    ///
    /// Parameter `original`: The original font descriptor reference.
    ///
    ///
    /// Parameter `featureTypeIdentifier`: The feature type identifier.
    ///
    ///
    /// Parameter `featureSelectorIdentifier`: The feature selector identifier.
    ///
    ///
    /// Returns: A copy of the original font descriptor modified with the given feature settings.
    ///
    ///
    /// See also: CTFontDescriptorCreateCopyWithAttributes
    ///
    /// See also: kCTFontFeatureSettingsAttribute
    #[doc(alias = "CTFontDescriptorCreateCopyWithFeature")]
    #[inline]
    pub unsafe fn copy_with_feature(
        &self,
        feature_type_identifier: &CFNumber,
        feature_selector_identifier: &CFNumber,
    ) -> CFRetained<CTFontDescriptor> {
        extern "C-unwind" {
            fn CTFontDescriptorCreateCopyWithFeature(
                original: &CTFontDescriptor,
                feature_type_identifier: &CFNumber,
                feature_selector_identifier: &CFNumber,
            ) -> Option<NonNull<CTFontDescriptor>>;
        }
        let ret = unsafe {
            CTFontDescriptorCreateCopyWithFeature(
                self,
                feature_type_identifier,
                feature_selector_identifier,
            )
        };
        let ret =
            ret.expect("function was marked as returning non-null, but actually returned NULL");
        unsafe { CFRetained::from_raw(ret) }
    }

    /// Returns an array of font normalized font descriptors matching the provided descriptor.
    ///
    ///
    /// Parameter `descriptor`: The font descriptor reference.
    ///
    ///
    /// Parameter `mandatoryAttributes`: A set of attribute keys which are required to be identically matched in any returned font descriptors. Optional.
    ///
    ///
    /// Returns: This function returns a retained array of normalized font descriptors matching the attributes present in descriptor. If descriptor itself is normalized then the array will contain only one item, the original descriptor.
    ///
    /// # Safety
    ///
    /// `mandatory_attributes` generic must be of the correct type.
    #[doc(alias = "CTFontDescriptorCreateMatchingFontDescriptors")]
    #[inline]
    pub unsafe fn matching_font_descriptors(
        &self,
        mandatory_attributes: Option<&CFSet>,
    ) -> Option<CFRetained<CFArray>> {
        extern "C-unwind" {
            fn CTFontDescriptorCreateMatchingFontDescriptors(
                descriptor: &CTFontDescriptor,
                mandatory_attributes: Option<&CFSet>,
            ) -> Option<NonNull<CFArray>>;
        }
        let ret =
            unsafe { CTFontDescriptorCreateMatchingFontDescriptors(self, mandatory_attributes) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Returns an the single preferred matching font descriptor based on the original descriptor and system precedence.
    ///
    ///
    /// Parameter `descriptor`: The font descriptor reference.
    ///
    ///
    /// Parameter `mandatoryAttributes`: A set of attribute keys which are required to be identically matched in any returned font descriptors. Optional.
    ///
    ///
    /// Returns: This function returns a retained normalized font descriptor matching the attributes present in descriptor. The original descriptor may be returned in normalized form.
    ///
    /// # Safety
    ///
    /// `mandatory_attributes` generic must be of the correct type.
    #[doc(alias = "CTFontDescriptorCreateMatchingFontDescriptor")]
    #[inline]
    pub unsafe fn matching_font_descriptor(
        &self,
        mandatory_attributes: Option<&CFSet>,
    ) -> Option<CFRetained<CTFontDescriptor>> {
        extern "C-unwind" {
            fn CTFontDescriptorCreateMatchingFontDescriptor(
                descriptor: &CTFontDescriptor,
                mandatory_attributes: Option<&CFSet>,
            ) -> Option<NonNull<CTFontDescriptor>>;
        }
        let ret =
            unsafe { CTFontDescriptorCreateMatchingFontDescriptor(self, mandatory_attributes) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }
}

/// Progress state
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontdescriptormatchingstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CTFontDescriptorMatchingState(pub u32);
impl CTFontDescriptorMatchingState {
    #[doc(alias = "kCTFontDescriptorMatchingDidBegin")]
    pub const DidBegin: Self = Self(0);
    #[doc(alias = "kCTFontDescriptorMatchingDidFinish")]
    pub const DidFinish: Self = Self(1);
    #[doc(alias = "kCTFontDescriptorMatchingWillBeginQuerying")]
    pub const WillBeginQuerying: Self = Self(2);
    #[doc(alias = "kCTFontDescriptorMatchingStalled")]
    pub const Stalled: Self = Self(3);
    #[doc(alias = "kCTFontDescriptorMatchingWillBeginDownloading")]
    pub const WillBeginDownloading: Self = Self(4);
    #[doc(alias = "kCTFontDescriptorMatchingDownloading")]
    pub const Downloading: Self = Self(5);
    #[doc(alias = "kCTFontDescriptorMatchingDidFinishDownloading")]
    pub const DidFinishDownloading: Self = Self(6);
    #[doc(alias = "kCTFontDescriptorMatchingDidMatch")]
    pub const DidMatch: Self = Self(7);
    #[doc(alias = "kCTFontDescriptorMatchingDidFailWithError")]
    pub const DidFailWithError: Self = Self(8);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CTFontDescriptorMatchingState {
    const ENCODING: Encoding = u32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTFontDescriptorMatchingState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingsourcedescriptor?language=objc)
    pub static kCTFontDescriptorMatchingSourceDescriptor: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingdescriptors?language=objc)
    pub static kCTFontDescriptorMatchingDescriptors: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingresult?language=objc)
    pub static kCTFontDescriptorMatchingResult: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingpercentage?language=objc)
    pub static kCTFontDescriptorMatchingPercentage: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingcurrentassetsize?language=objc)
    pub static kCTFontDescriptorMatchingCurrentAssetSize: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingtotaldownloadedsize?language=objc)
    pub static kCTFontDescriptorMatchingTotalDownloadedSize: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingtotalassetsize?language=objc)
    pub static kCTFontDescriptorMatchingTotalAssetSize: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingerror?language=objc)
    pub static kCTFontDescriptorMatchingError: &'static CFString;
}

/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontdescriptorprogresshandler?language=objc)
#[cfg(feature = "block2")]
pub type CTFontDescriptorProgressHandler =
    *mut block2::DynBlock<dyn Fn(CTFontDescriptorMatchingState, NonNull<CFDictionary>) -> bool>;

impl CTFontDescriptor {
    /// # Safety
    ///
    /// - `descriptors` generic must be of the correct type.
    /// - `mandatory_attributes` generic must be of the correct type.
    /// - `progress_block` must be a valid pointer.
    #[doc(alias = "CTFontDescriptorMatchFontDescriptorsWithProgressHandler")]
    #[cfg(feature = "block2")]
    #[inline]
    pub unsafe fn match_font_descriptors_with_progress_handler(
        descriptors: &CFArray,
        mandatory_attributes: Option<&CFSet>,
        progress_block: CTFontDescriptorProgressHandler,
    ) -> bool {
        extern "C-unwind" {
            fn CTFontDescriptorMatchFontDescriptorsWithProgressHandler(
                descriptors: &CFArray,
                mandatory_attributes: Option<&CFSet>,
                progress_block: CTFontDescriptorProgressHandler,
            ) -> bool;
        }
        unsafe {
            CTFontDescriptorMatchFontDescriptorsWithProgressHandler(
                descriptors,
                mandatory_attributes,
                progress_block,
            )
        }
    }

    /// Returns the attributes dictionary of the font descriptor.
    ///
    ///
    /// Parameter `descriptor`: The font descriptor reference.
    ///
    ///
    /// Returns: A retained reference to the font descriptor attributes dictionary. This dictionary will contain the minimum number of attributes to fully specify this particular font descriptor.
    #[doc(alias = "CTFontDescriptorCopyAttributes")]
    #[inline]
    pub unsafe fn attributes(&self) -> CFRetained<CFDictionary> {
        extern "C-unwind" {
            fn CTFontDescriptorCopyAttributes(
                descriptor: &CTFontDescriptor,
            ) -> Option<NonNull<CFDictionary>>;
        }
        let ret = unsafe { CTFontDescriptorCopyAttributes(self) };
        let ret =
            ret.expect("function was marked as returning non-null, but actually returned NULL");
        unsafe { CFRetained::from_raw(ret) }
    }

    /// Returns the value associated with an arbitrary attribute.
    ///
    ///
    /// Parameter `descriptor`: The font descriptor.
    ///
    ///
    /// Parameter `attribute`: The requested attribute.
    ///
    ///
    /// Returns: A retained reference to the requested attribute, or NULL if the requested attribute is not present. Refer to the attribute definitions for documentation as to how each attribute is packaged as a CFType.
    #[doc(alias = "CTFontDescriptorCopyAttribute")]
    #[inline]
    pub unsafe fn attribute(&self, attribute: &CFString) -> Option<CFRetained<CFType>> {
        extern "C-unwind" {
            fn CTFontDescriptorCopyAttribute(
                descriptor: &CTFontDescriptor,
                attribute: &CFString,
            ) -> Option<NonNull<CFType>>;
        }
        let ret = unsafe { CTFontDescriptorCopyAttribute(self, attribute) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// function    CTFontDescriptorCopyLocalizedAttribute
    ///
    /// Returns a localized value for the requested attribute if available.
    ///
    ///
    /// This function returns a localized attribute based on the global language list. If localization is not possible for the attribute the behavior matches CTFontDescriptorCopyAttribute(). Generally, localization of attributes is only applicable to name attributes of a normalized font descriptor.
    ///
    ///
    /// Parameter `descriptor`: The font descriptor reference.
    ///
    ///
    /// Parameter `attribute`: The requested font attribute.
    ///
    ///
    /// Parameter `language`: If non-NULL, this will be receive a retained reference to the matched language. The language identifier will conform to UTS #35.
    /// If CoreText can supply its own localized string where the font cannot, this value will be NULL.
    ///
    ///
    /// Returns: A retained reference to the requested attribute, or NULL if the requested attribute is not present. Refer to the attribute definitions for documentation as to how each attribute is packaged as a CFType.
    ///
    /// # Safety
    ///
    /// `language` must be a valid pointer or null.
    #[doc(alias = "CTFontDescriptorCopyLocalizedAttribute")]
    #[inline]
    pub unsafe fn localized_attribute(
        &self,
        attribute: &CFString,
        language: *mut *const CFString,
    ) -> Option<CFRetained<CFType>> {
        extern "C-unwind" {
            fn CTFontDescriptorCopyLocalizedAttribute(
                descriptor: &CTFontDescriptor,
                attribute: &CFString,
                language: *mut *const CFString,
            ) -> Option<NonNull<CFType>>;
        }
        let ret = unsafe { CTFontDescriptorCopyLocalizedAttribute(self, attribute, language) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }
}

#[deprecated = "renamed to `CTFontDescriptor::with_name_and_size`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCreateWithNameAndSize(
    name: &CFString,
    size: CGFloat,
) -> CFRetained<CTFontDescriptor> {
    extern "C-unwind" {
        fn CTFontDescriptorCreateWithNameAndSize(
            name: &CFString,
            size: CGFloat,
        ) -> Option<NonNull<CTFontDescriptor>>;
    }
    let ret = unsafe { CTFontDescriptorCreateWithNameAndSize(name, size) };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}

#[deprecated = "renamed to `CTFontDescriptor::with_attributes`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCreateWithAttributes(
    attributes: &CFDictionary,
) -> CFRetained<CTFontDescriptor> {
    extern "C-unwind" {
        fn CTFontDescriptorCreateWithAttributes(
            attributes: &CFDictionary,
        ) -> Option<NonNull<CTFontDescriptor>>;
    }
    let ret = unsafe { CTFontDescriptorCreateWithAttributes(attributes) };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}

#[deprecated = "renamed to `CTFontDescriptor::copy_with_attributes`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithAttributes(
    original: &CTFontDescriptor,
    attributes: &CFDictionary,
) -> CFRetained<CTFontDescriptor> {
    extern "C-unwind" {
        fn CTFontDescriptorCreateCopyWithAttributes(
            original: &CTFontDescriptor,
            attributes: &CFDictionary,
        ) -> Option<NonNull<CTFontDescriptor>>;
    }
    let ret = unsafe { CTFontDescriptorCreateCopyWithAttributes(original, attributes) };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}

#[deprecated = "renamed to `CTFontDescriptor::copy_with_family`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithFamily(
    original: &CTFontDescriptor,
    family: &CFString,
) -> Option<CFRetained<CTFontDescriptor>> {
    extern "C-unwind" {
        fn CTFontDescriptorCreateCopyWithFamily(
            original: &CTFontDescriptor,
            family: &CFString,
        ) -> Option<NonNull<CTFontDescriptor>>;
    }
    let ret = unsafe { CTFontDescriptorCreateCopyWithFamily(original, family) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CTFontTraits")]
#[deprecated = "renamed to `CTFontDescriptor::copy_with_symbolic_traits`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithSymbolicTraits(
    original: &CTFontDescriptor,
    sym_trait_value: CTFontSymbolicTraits,
    sym_trait_mask: CTFontSymbolicTraits,
) -> Option<CFRetained<CTFontDescriptor>> {
    extern "C-unwind" {
        fn CTFontDescriptorCreateCopyWithSymbolicTraits(
            original: &CTFontDescriptor,
            sym_trait_value: CTFontSymbolicTraits,
            sym_trait_mask: CTFontSymbolicTraits,
        ) -> Option<NonNull<CTFontDescriptor>>;
    }
    let ret = unsafe {
        CTFontDescriptorCreateCopyWithSymbolicTraits(original, sym_trait_value, sym_trait_mask)
    };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CTFontDescriptor::copy_with_variation`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithVariation(
    original: &CTFontDescriptor,
    variation_identifier: &CFNumber,
    variation_value: CGFloat,
) -> CFRetained<CTFontDescriptor> {
    extern "C-unwind" {
        fn CTFontDescriptorCreateCopyWithVariation(
            original: &CTFontDescriptor,
            variation_identifier: &CFNumber,
            variation_value: CGFloat,
        ) -> Option<NonNull<CTFontDescriptor>>;
    }
    let ret = unsafe {
        CTFontDescriptorCreateCopyWithVariation(original, variation_identifier, variation_value)
    };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}

#[deprecated = "renamed to `CTFontDescriptor::copy_with_feature`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithFeature(
    original: &CTFontDescriptor,
    feature_type_identifier: &CFNumber,
    feature_selector_identifier: &CFNumber,
) -> CFRetained<CTFontDescriptor> {
    extern "C-unwind" {
        fn CTFontDescriptorCreateCopyWithFeature(
            original: &CTFontDescriptor,
            feature_type_identifier: &CFNumber,
            feature_selector_identifier: &CFNumber,
        ) -> Option<NonNull<CTFontDescriptor>>;
    }
    let ret = unsafe {
        CTFontDescriptorCreateCopyWithFeature(
            original,
            feature_type_identifier,
            feature_selector_identifier,
        )
    };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}

#[deprecated = "renamed to `CTFontDescriptor::matching_font_descriptors`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCreateMatchingFontDescriptors(
    descriptor: &CTFontDescriptor,
    mandatory_attributes: Option<&CFSet>,
) -> Option<CFRetained<CFArray>> {
    extern "C-unwind" {
        fn CTFontDescriptorCreateMatchingFontDescriptors(
            descriptor: &CTFontDescriptor,
            mandatory_attributes: Option<&CFSet>,
        ) -> Option<NonNull<CFArray>>;
    }
    let ret =
        unsafe { CTFontDescriptorCreateMatchingFontDescriptors(descriptor, mandatory_attributes) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CTFontDescriptor::matching_font_descriptor`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCreateMatchingFontDescriptor(
    descriptor: &CTFontDescriptor,
    mandatory_attributes: Option<&CFSet>,
) -> Option<CFRetained<CTFontDescriptor>> {
    extern "C-unwind" {
        fn CTFontDescriptorCreateMatchingFontDescriptor(
            descriptor: &CTFontDescriptor,
            mandatory_attributes: Option<&CFSet>,
        ) -> Option<NonNull<CTFontDescriptor>>;
    }
    let ret =
        unsafe { CTFontDescriptorCreateMatchingFontDescriptor(descriptor, mandatory_attributes) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

extern "C-unwind" {
    #[cfg(feature = "block2")]
    #[deprecated = "renamed to `CTFontDescriptor::match_font_descriptors_with_progress_handler`"]
    pub fn CTFontDescriptorMatchFontDescriptorsWithProgressHandler(
        descriptors: &CFArray,
        mandatory_attributes: Option<&CFSet>,
        progress_block: CTFontDescriptorProgressHandler,
    ) -> bool;
}

#[deprecated = "renamed to `CTFontDescriptor::attributes`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCopyAttributes(
    descriptor: &CTFontDescriptor,
) -> CFRetained<CFDictionary> {
    extern "C-unwind" {
        fn CTFontDescriptorCopyAttributes(
            descriptor: &CTFontDescriptor,
        ) -> Option<NonNull<CFDictionary>>;
    }
    let ret = unsafe { CTFontDescriptorCopyAttributes(descriptor) };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}

#[deprecated = "renamed to `CTFontDescriptor::attribute`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCopyAttribute(
    descriptor: &CTFontDescriptor,
    attribute: &CFString,
) -> Option<CFRetained<CFType>> {
    extern "C-unwind" {
        fn CTFontDescriptorCopyAttribute(
            descriptor: &CTFontDescriptor,
            attribute: &CFString,
        ) -> Option<NonNull<CFType>>;
    }
    let ret = unsafe { CTFontDescriptorCopyAttribute(descriptor, attribute) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CTFontDescriptor::localized_attribute`"]
#[inline]
pub unsafe extern "C-unwind" fn CTFontDescriptorCopyLocalizedAttribute(
    descriptor: &CTFontDescriptor,
    attribute: &CFString,
    language: *mut *const CFString,
) -> Option<CFRetained<CFType>> {
    extern "C-unwind" {
        fn CTFontDescriptorCopyLocalizedAttribute(
            descriptor: &CTFontDescriptor,
            attribute: &CFString,
            language: *mut *const CFString,
        ) -> Option<NonNull<CFType>>;
    }
    let ret = unsafe { CTFontDescriptorCopyLocalizedAttribute(descriptor, attribute, language) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}