objc2_core_text/generated/
CTFontDescriptor.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontdescriptor?language=objc)
14#[repr(C)]
15pub struct CTFontDescriptor {
16    inner: [u8; 0],
17    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20cf_type!(
21    #[encoding_name = "__CTFontDescriptor"]
22    unsafe impl CTFontDescriptor {}
23);
24
25unsafe impl ConcreteType for CTFontDescriptor {
26    /// Returns the type identifier for Core Text font descriptor
27    /// references.
28    ///
29    /// Returns: The identifier for the opaque type CTFontDescriptorRef.
30    #[doc(alias = "CTFontDescriptorGetTypeID")]
31    #[inline]
32    fn type_id() -> CFTypeID {
33        extern "C-unwind" {
34            fn CTFontDescriptorGetTypeID() -> CFTypeID;
35        }
36        unsafe { CTFontDescriptorGetTypeID() }
37    }
38}
39
40extern "C" {
41    /// kCTFontURLAttribute
42    ///
43    /// The font URL.
44    ///
45    /// This is the key for accessing the font URL from the font descriptor. The value associated with this key is a CFURLRef.
46    ///
47    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonturlattribute?language=objc)
48    pub static kCTFontURLAttribute: &'static CFString;
49}
50
51extern "C" {
52    /// kCTFontNameAttribute
53    ///
54    /// The PostScript name.
55    ///
56    /// 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.
57    ///
58    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontnameattribute?language=objc)
59    pub static kCTFontNameAttribute: &'static CFString;
60}
61
62extern "C" {
63    /// kCTFontDisplayNameAttribute
64    ///
65    /// The display name.
66    ///
67    /// 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.
68    ///
69    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdisplaynameattribute?language=objc)
70    pub static kCTFontDisplayNameAttribute: &'static CFString;
71}
72
73extern "C" {
74    /// kCTFontFamilyNameAttribute
75    ///
76    /// The family name.
77    ///
78    /// This is the key for accessing the family name from the font descriptor. The value associated with this key is a CFStringRef.
79    ///
80    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfamilynameattribute?language=objc)
81    pub static kCTFontFamilyNameAttribute: &'static CFString;
82}
83
84extern "C" {
85    /// kCTFontStyleNameAttribute
86    ///
87    /// The style name.
88    ///
89    /// 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.
90    ///
91    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontstylenameattribute?language=objc)
92    pub static kCTFontStyleNameAttribute: &'static CFString;
93}
94
95extern "C" {
96    /// kCTFontTraitsAttribute
97    ///
98    /// The font traits dictionary.
99    ///
100    /// 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.
101    ///
102    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttraitsattribute?language=objc)
103    pub static kCTFontTraitsAttribute: &'static CFString;
104}
105
106extern "C" {
107    /// kCTFontVariationAttribute
108    ///
109    /// The font variation dictionary.
110    ///
111    /// 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.
112    ///
113    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationattribute?language=objc)
114    pub static kCTFontVariationAttribute: &'static CFString;
115}
116
117extern "C" {
118    /// kCTFontVariationAxesAttribute
119    ///
120    /// An array of variation axis dictionaries or null if the font does not support variations. Each variation axis dictionary contains the five kCTFontVariationAxis* keys.
121    /// Before macOS 13.0 and iOS 16.0 this attribute is not accurate and CTFontCopyVariationAxes() should be used instead.
122    ///
123    /// See also: CTFontCopyVariationAxes
124    ///
125    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationaxesattribute?language=objc)
126    pub static kCTFontVariationAxesAttribute: &'static CFString;
127}
128
129extern "C" {
130    /// kCTFontSizeAttribute
131    ///
132    /// The font point size.
133    ///
134    /// 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.
135    ///
136    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontsizeattribute?language=objc)
137    pub static kCTFontSizeAttribute: &'static CFString;
138}
139
140extern "C" {
141    /// kCTFontMatrixAttribute
142    ///
143    /// The font transformation matrix.
144    ///
145    /// 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.
146    ///
147    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontmatrixattribute?language=objc)
148    pub static kCTFontMatrixAttribute: &'static CFString;
149}
150
151extern "C" {
152    /// kCTFontCascadeListAttribute
153    ///
154    /// The font cascade list.
155    ///
156    /// 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.
157    ///
158    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontcascadelistattribute?language=objc)
159    pub static kCTFontCascadeListAttribute: &'static CFString;
160}
161
162extern "C" {
163    /// kCTFontCharacterSetAttribute
164    ///
165    /// The font Unicode character coverage set.
166    ///
167    /// 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.
168    ///
169    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontcharactersetattribute?language=objc)
170    pub static kCTFontCharacterSetAttribute: &'static CFString;
171}
172
173extern "C" {
174    /// kCTFontLanguagesAttribute
175    ///
176    /// The list of supported languages.
177    ///
178    /// 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.
179    ///
180    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontlanguagesattribute?language=objc)
181    pub static kCTFontLanguagesAttribute: &'static CFString;
182}
183
184extern "C" {
185    /// kCTFontBaselineAdjustAttribute
186    ///
187    /// The baseline adjustment to apply to font metrics.
188    ///
189    /// 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.
190    ///
191    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontbaselineadjustattribute?language=objc)
192    pub static kCTFontBaselineAdjustAttribute: &'static CFString;
193}
194
195extern "C" {
196    /// kCTFontMacintoshEncodingsAttribute
197    ///
198    /// The Macintosh encodings (legacy script codes).
199    ///
200    /// The value associated with this key is a CFNumberRef containing a bitfield of the script codes in
201    /// <CoreText
202    /// /SFNTTypes.h>; bit 0 corresponds to kFontRomanScript, and so on. This attribute is provided for legacy compatibility.
203    ///
204    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontmacintoshencodingsattribute?language=objc)
205    pub static kCTFontMacintoshEncodingsAttribute: &'static CFString;
206}
207
208extern "C" {
209    /// kCTFontFeaturesAttribute
210    ///
211    /// The array of font features.
212    ///
213    /// 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. This features list contains the feature information from the 'feat' table of the font. See the CTFontCopyFeatures() API in   CTFont.h.
214    ///
215    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturesattribute?language=objc)
216    pub static kCTFontFeaturesAttribute: &'static CFString;
217}
218
219extern "C" {
220    /// kCTFontFeatureSettingsAttribute
221    ///
222    /// The array of typographic feature settings.
223    ///
224    /// 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.
225    /// An AAT setting dictionary contains a tuple of a kCTFontFeatureTypeIdentifierKey key-value pair and a kCTFontFeatureSelectorIdentifierKey key-value pair.
226    /// An OpenType setting dictionary contains a tuple of a kCTFontOpenTypeFeatureTag key-value pair and a kCTFontOpenTypeFeatureValue key-value pair.
227    ///
228    /// Starting with OS X 10.10 and iOS 8.0, settings are also accepted (but not returned) in the following simplified forms:
229    /// An OpenType setting can be either an array pair of tag string and value number, or a tag string on its own. For example:
230    /// @
231    /// [
232    /// "
233    /// c2sc", @1 ] or simply @"c2sc". An unspecified value enables the feature and a value of zero disables it.
234    /// An AAT setting can be specified as an array pair of type and selector numbers. For example:
235    /// @
236    /// [
237    /// @
238    /// (kUpperCaseType),
239    /// @
240    /// (kUpperCaseSmallCapsSelector) ].
241    ///
242    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturesettingsattribute?language=objc)
243    pub static kCTFontFeatureSettingsAttribute: &'static CFString;
244}
245
246extern "C" {
247    /// kCTFontFixedAdvanceAttribute
248    ///
249    /// Specifies advance width.
250    ///
251    /// 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.
252    ///
253    /// 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.
254    ///
255    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfixedadvanceattribute?language=objc)
256    pub static kCTFontFixedAdvanceAttribute: &'static CFString;
257}
258
259extern "C" {
260    /// kCTFontOrientationAttribute
261    ///
262    /// The orientation attribute.
263    ///
264    /// 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.
265    ///
266    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontorientationattribute?language=objc)
267    pub static kCTFontOrientationAttribute: &'static CFString;
268}
269
270/// Specifies the intended rendering orientation of the font for obtaining glyph metrics.
271///
272/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontorientation?language=objc)
273// NS_ENUM
274#[repr(transparent)]
275#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
276pub struct CTFontOrientation(pub u32);
277impl CTFontOrientation {
278    #[doc(alias = "kCTFontOrientationDefault")]
279    pub const Default: Self = Self(0);
280    #[doc(alias = "kCTFontOrientationHorizontal")]
281    pub const Horizontal: Self = Self(1);
282    #[doc(alias = "kCTFontOrientationVertical")]
283    pub const Vertical: Self = Self(2);
284    #[deprecated = "Deprecated"]
285    pub const kCTFontDefaultOrientation: Self = Self(CTFontOrientation::Default.0);
286    #[deprecated = "Deprecated"]
287    pub const kCTFontHorizontalOrientation: Self = Self(CTFontOrientation::Horizontal.0);
288    #[deprecated = "Deprecated"]
289    pub const kCTFontVerticalOrientation: Self = Self(CTFontOrientation::Vertical.0);
290}
291
292#[cfg(feature = "objc2")]
293unsafe impl Encode for CTFontOrientation {
294    const ENCODING: Encoding = u32::ENCODING;
295}
296
297#[cfg(feature = "objc2")]
298unsafe impl RefEncode for CTFontOrientation {
299    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
300}
301
302extern "C" {
303    /// kCTFontFormatAttribute
304    ///
305    /// Specifies the recognized format of the font.
306    ///
307    /// 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.
308    ///
309    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontformatattribute?language=objc)
310    pub static kCTFontFormatAttribute: &'static CFString;
311}
312
313/// The font is not a recognized format
314///
315/// The font is an OpenType format containing PostScript data
316///
317/// The font is an OpenType format containing TrueType data
318///
319/// The font is a recognized TrueType format
320///
321/// The font is a recognized PostScript format
322///
323/// The font is a bitmap only format
324///
325/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontformat?language=objc)
326// NS_ENUM
327#[repr(transparent)]
328#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
329pub struct CTFontFormat(pub u32);
330impl CTFontFormat {
331    #[doc(alias = "kCTFontFormatUnrecognized")]
332    pub const Unrecognized: Self = Self(0);
333    #[doc(alias = "kCTFontFormatOpenTypePostScript")]
334    pub const OpenTypePostScript: Self = Self(1);
335    #[doc(alias = "kCTFontFormatOpenTypeTrueType")]
336    pub const OpenTypeTrueType: Self = Self(2);
337    #[doc(alias = "kCTFontFormatTrueType")]
338    pub const TrueType: Self = Self(3);
339    #[doc(alias = "kCTFontFormatPostScript")]
340    pub const PostScript: Self = Self(4);
341    #[doc(alias = "kCTFontFormatBitmap")]
342    pub const Bitmap: Self = Self(5);
343}
344
345#[cfg(feature = "objc2")]
346unsafe impl Encode for CTFontFormat {
347    const ENCODING: Encoding = u32::ENCODING;
348}
349
350#[cfg(feature = "objc2")]
351unsafe impl RefEncode for CTFontFormat {
352    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
353}
354
355extern "C" {
356    /// kCTFontRegistrationScopeAttribute
357    ///
358    /// Specifies the font descriptor's registration scope.
359    ///
360    /// 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.
361    ///
362    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontregistrationscopeattribute?language=objc)
363    pub static kCTFontRegistrationScopeAttribute: &'static CFString;
364}
365
366extern "C" {
367    /// kCTFontPriorityAttribute
368    ///
369    /// The font descriptors priority when resolving duplicates and sorting match results.
370    ///
371    /// 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.
372    ///
373    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpriorityattribute?language=objc)
374    pub static kCTFontPriorityAttribute: &'static CFString;
375}
376
377/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritysystem?language=objc)
378pub const kCTFontPrioritySystem: c_uint = 10000;
379/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritynetwork?language=objc)
380pub const kCTFontPriorityNetwork: c_uint = 20000;
381/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritycomputer?language=objc)
382pub const kCTFontPriorityComputer: c_uint = 30000;
383/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpriorityuser?language=objc)
384pub const kCTFontPriorityUser: c_uint = 40000;
385/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritydynamic?language=objc)
386pub const kCTFontPriorityDynamic: c_uint = 50000;
387/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpriorityprocess?language=objc)
388pub const kCTFontPriorityProcess: c_uint = 60000;
389
390/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontpriority?language=objc)
391pub type CTFontPriority = u32;
392
393extern "C" {
394    /// kCTFontEnabledAttribute
395    ///
396    /// The font enabled state.
397    ///
398    /// The value associated with this key is a CFBoolean. Unregistered font descriptors will return NULL, which is equivalent to false.
399    ///
400    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontenabledattribute?language=objc)
401    pub static kCTFontEnabledAttribute: &'static CFString;
402}
403
404extern "C" {
405    /// kCTFontDownloadableAttribute
406    ///
407    /// The font downloadable state.
408    ///
409    /// 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.
410    ///
411    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdownloadableattribute?language=objc)
412    pub static kCTFontDownloadableAttribute: &'static CFString;
413}
414
415extern "C" {
416    /// kCTFontDownloadedAttribute
417    ///
418    /// The download state.
419    ///
420    /// 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.)
421    ///
422    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdownloadedattribute?language=objc)
423    pub static kCTFontDownloadedAttribute: &'static CFString;
424}
425
426extern "C" {
427    /// kCTFontOpticalSizeAttribute
428    ///
429    /// The point size at which this font is intended to be used.
430    ///
431    /// 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.
432    ///
433    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontopticalsizeattribute?language=objc)
434    pub static kCTFontOpticalSizeAttribute: &'static CFString;
435}
436
437/// Creates a new font descriptor with the provided PostScript name and size.
438///
439///
440/// 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.
441///
442///
443/// Parameter `size`: The point size. If 0.0, the kCTFontSizeAttribute will be omitted from the font descriptor.
444///
445///
446/// Returns: This function creates a new font descriptor reference with the given PostScript name and point size.
447///
448///
449/// 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.
450#[inline]
451pub unsafe extern "C-unwind" fn CTFontDescriptorCreateWithNameAndSize(
452    name: &CFString,
453    size: CGFloat,
454) -> CFRetained<CTFontDescriptor> {
455    extern "C-unwind" {
456        fn CTFontDescriptorCreateWithNameAndSize(
457            name: &CFString,
458            size: CGFloat,
459        ) -> Option<NonNull<CTFontDescriptor>>;
460    }
461    let ret = unsafe { CTFontDescriptorCreateWithNameAndSize(name, size) };
462    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
463    unsafe { CFRetained::from_raw(ret) }
464}
465
466/// Creates a new font descriptor reference from a dictionary of attributes.
467///
468///
469/// Parameter `attributes`: A CFDictionaryRef of arbitrary attributes.
470///
471///
472/// 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).
473#[inline]
474pub unsafe extern "C-unwind" fn CTFontDescriptorCreateWithAttributes(
475    attributes: &CFDictionary,
476) -> CFRetained<CTFontDescriptor> {
477    extern "C-unwind" {
478        fn CTFontDescriptorCreateWithAttributes(
479            attributes: &CFDictionary,
480        ) -> Option<NonNull<CTFontDescriptor>>;
481    }
482    let ret = unsafe { CTFontDescriptorCreateWithAttributes(attributes) };
483    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
484    unsafe { CFRetained::from_raw(ret) }
485}
486
487/// Creates a copy of the original font descriptor with new attributes.
488///
489///
490/// Parameter `original`: The original font descriptor reference.
491///
492///
493/// Parameter `attributes`: A CFDictionaryRef of arbitrary attributes.
494///
495///
496/// 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.
497///
498/// 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
499/// @
500/// { (id)kCTFontFeatureTypeIdentifierKey:
501/// @
502/// (kLigaturesType), (id)kCTFontFeatureSelectorIdentifierKey: (id)kCFNull } means clear the kLigatureType feature set in the original font descriptor. An element like
503/// @
504/// [
505/// "
506/// liga", (id)kCFNull ] will have the same effect.
507#[inline]
508pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithAttributes(
509    original: &CTFontDescriptor,
510    attributes: &CFDictionary,
511) -> CFRetained<CTFontDescriptor> {
512    extern "C-unwind" {
513        fn CTFontDescriptorCreateCopyWithAttributes(
514            original: &CTFontDescriptor,
515            attributes: &CFDictionary,
516        ) -> Option<NonNull<CTFontDescriptor>>;
517    }
518    let ret = unsafe { CTFontDescriptorCreateCopyWithAttributes(original, attributes) };
519    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
520    unsafe { CFRetained::from_raw(ret) }
521}
522
523/// Returns a new font descriptor in the specified family based on the traits of the original descriptor.
524///
525///
526/// Parameter `original`: The original font descriptor reference.
527///
528///
529/// Parameter `family`: The name of the desired family.
530///
531///
532/// Returns: Returns a new font reference with the original traits in the given family, or NULL if none found in the system.
533#[inline]
534pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithFamily(
535    original: &CTFontDescriptor,
536    family: &CFString,
537) -> Option<CFRetained<CTFontDescriptor>> {
538    extern "C-unwind" {
539        fn CTFontDescriptorCreateCopyWithFamily(
540            original: &CTFontDescriptor,
541            family: &CFString,
542        ) -> Option<NonNull<CTFontDescriptor>>;
543    }
544    let ret = unsafe { CTFontDescriptorCreateCopyWithFamily(original, family) };
545    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
546}
547
548/// Returns a new font descriptor based on the original descriptor having the specified symbolic traits.
549///
550///
551/// Parameter `original`: The original font descriptor reference.
552///
553///
554/// 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.
555///
556///
557/// Parameter `symTraitMask`: The mask bits of the symbolic traits. This bitfield is used to indicate the traits that should be changed.
558///
559///
560/// Returns: Returns a new font descriptor reference in the same family with the given symbolic traits, or NULL if none found in the system.
561#[cfg(feature = "CTFontTraits")]
562#[inline]
563pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithSymbolicTraits(
564    original: &CTFontDescriptor,
565    sym_trait_value: CTFontSymbolicTraits,
566    sym_trait_mask: CTFontSymbolicTraits,
567) -> Option<CFRetained<CTFontDescriptor>> {
568    extern "C-unwind" {
569        fn CTFontDescriptorCreateCopyWithSymbolicTraits(
570            original: &CTFontDescriptor,
571            sym_trait_value: CTFontSymbolicTraits,
572            sym_trait_mask: CTFontSymbolicTraits,
573        ) -> Option<NonNull<CTFontDescriptor>>;
574    }
575    let ret = unsafe {
576        CTFontDescriptorCreateCopyWithSymbolicTraits(original, sym_trait_value, sym_trait_mask)
577    };
578    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
579}
580
581/// Creates a copy of the original font descriptor with a new variation instance.
582///
583///
584/// Parameter `original`: The original font descriptor reference.
585///
586///
587/// Parameter `variationIdentifier`: The variation axis identifier. This is the four character code of the variation axis as a CFNumberRef.
588///
589///
590/// Parameter `variationValue`: The value corresponding with the variation instance.
591///
592///
593/// 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.
594#[inline]
595pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithVariation(
596    original: &CTFontDescriptor,
597    variation_identifier: &CFNumber,
598    variation_value: CGFloat,
599) -> CFRetained<CTFontDescriptor> {
600    extern "C-unwind" {
601        fn CTFontDescriptorCreateCopyWithVariation(
602            original: &CTFontDescriptor,
603            variation_identifier: &CFNumber,
604            variation_value: CGFloat,
605        ) -> Option<NonNull<CTFontDescriptor>>;
606    }
607    let ret = unsafe {
608        CTFontDescriptorCreateCopyWithVariation(original, variation_identifier, variation_value)
609    };
610    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
611    unsafe { CFRetained::from_raw(ret) }
612}
613
614/// Copies a font descriptor with new feature setting.
615///
616///
617/// This is a convenience method to more easily toggle the state of individual features.
618///
619///
620/// Parameter `original`: The original font descriptor reference.
621///
622///
623/// Parameter `featureTypeIdentifier`: The feature type identifier.
624///
625///
626/// Parameter `featureSelectorIdentifier`: The feature selector identifier.
627///
628///
629/// Returns: A copy of the original font descriptor modified with the given feature settings.
630#[inline]
631pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithFeature(
632    original: &CTFontDescriptor,
633    feature_type_identifier: &CFNumber,
634    feature_selector_identifier: &CFNumber,
635) -> CFRetained<CTFontDescriptor> {
636    extern "C-unwind" {
637        fn CTFontDescriptorCreateCopyWithFeature(
638            original: &CTFontDescriptor,
639            feature_type_identifier: &CFNumber,
640            feature_selector_identifier: &CFNumber,
641        ) -> Option<NonNull<CTFontDescriptor>>;
642    }
643    let ret = unsafe {
644        CTFontDescriptorCreateCopyWithFeature(
645            original,
646            feature_type_identifier,
647            feature_selector_identifier,
648        )
649    };
650    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
651    unsafe { CFRetained::from_raw(ret) }
652}
653
654/// Returns an array of font normalized font descriptors matching the provided descriptor.
655///
656///
657/// Parameter `descriptor`: The font descriptor reference.
658///
659///
660/// Parameter `mandatoryAttributes`: A set of attribute keys which are required to be identically matched in any returned font descriptors. Optional.
661///
662///
663/// 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.
664#[inline]
665pub unsafe extern "C-unwind" fn CTFontDescriptorCreateMatchingFontDescriptors(
666    descriptor: &CTFontDescriptor,
667    mandatory_attributes: Option<&CFSet>,
668) -> Option<CFRetained<CFArray>> {
669    extern "C-unwind" {
670        fn CTFontDescriptorCreateMatchingFontDescriptors(
671            descriptor: &CTFontDescriptor,
672            mandatory_attributes: Option<&CFSet>,
673        ) -> Option<NonNull<CFArray>>;
674    }
675    let ret =
676        unsafe { CTFontDescriptorCreateMatchingFontDescriptors(descriptor, mandatory_attributes) };
677    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
678}
679
680/// Returns an the single preferred matching font descriptor based on the original descriptor and system precedence.
681///
682///
683/// Parameter `descriptor`: The font descriptor reference.
684///
685///
686/// Parameter `mandatoryAttributes`: A set of attribute keys which are required to be identically matched in any returned font descriptors. Optional.
687///
688///
689/// Returns: This function returns a retained normalized font descriptor matching the attributes present in descriptor. The original descriptor may be returned in normalized form.
690#[inline]
691pub unsafe extern "C-unwind" fn CTFontDescriptorCreateMatchingFontDescriptor(
692    descriptor: &CTFontDescriptor,
693    mandatory_attributes: Option<&CFSet>,
694) -> Option<CFRetained<CTFontDescriptor>> {
695    extern "C-unwind" {
696        fn CTFontDescriptorCreateMatchingFontDescriptor(
697            descriptor: &CTFontDescriptor,
698            mandatory_attributes: Option<&CFSet>,
699        ) -> Option<NonNull<CTFontDescriptor>>;
700    }
701    let ret =
702        unsafe { CTFontDescriptorCreateMatchingFontDescriptor(descriptor, mandatory_attributes) };
703    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
704}
705
706/// Progress state
707///
708/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontdescriptormatchingstate?language=objc)
709// NS_ENUM
710#[repr(transparent)]
711#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
712pub struct CTFontDescriptorMatchingState(pub u32);
713impl CTFontDescriptorMatchingState {
714    #[doc(alias = "kCTFontDescriptorMatchingDidBegin")]
715    pub const DidBegin: Self = Self(0);
716    #[doc(alias = "kCTFontDescriptorMatchingDidFinish")]
717    pub const DidFinish: Self = Self(1);
718    #[doc(alias = "kCTFontDescriptorMatchingWillBeginQuerying")]
719    pub const WillBeginQuerying: Self = Self(2);
720    #[doc(alias = "kCTFontDescriptorMatchingStalled")]
721    pub const Stalled: Self = Self(3);
722    #[doc(alias = "kCTFontDescriptorMatchingWillBeginDownloading")]
723    pub const WillBeginDownloading: Self = Self(4);
724    #[doc(alias = "kCTFontDescriptorMatchingDownloading")]
725    pub const Downloading: Self = Self(5);
726    #[doc(alias = "kCTFontDescriptorMatchingDidFinishDownloading")]
727    pub const DidFinishDownloading: Self = Self(6);
728    #[doc(alias = "kCTFontDescriptorMatchingDidMatch")]
729    pub const DidMatch: Self = Self(7);
730    #[doc(alias = "kCTFontDescriptorMatchingDidFailWithError")]
731    pub const DidFailWithError: Self = Self(8);
732}
733
734#[cfg(feature = "objc2")]
735unsafe impl Encode for CTFontDescriptorMatchingState {
736    const ENCODING: Encoding = u32::ENCODING;
737}
738
739#[cfg(feature = "objc2")]
740unsafe impl RefEncode for CTFontDescriptorMatchingState {
741    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
742}
743
744extern "C" {
745    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingsourcedescriptor?language=objc)
746    pub static kCTFontDescriptorMatchingSourceDescriptor: &'static CFString;
747}
748
749extern "C" {
750    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingdescriptors?language=objc)
751    pub static kCTFontDescriptorMatchingDescriptors: &'static CFString;
752}
753
754extern "C" {
755    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingresult?language=objc)
756    pub static kCTFontDescriptorMatchingResult: &'static CFString;
757}
758
759extern "C" {
760    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingpercentage?language=objc)
761    pub static kCTFontDescriptorMatchingPercentage: &'static CFString;
762}
763
764extern "C" {
765    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingcurrentassetsize?language=objc)
766    pub static kCTFontDescriptorMatchingCurrentAssetSize: &'static CFString;
767}
768
769extern "C" {
770    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingtotaldownloadedsize?language=objc)
771    pub static kCTFontDescriptorMatchingTotalDownloadedSize: &'static CFString;
772}
773
774extern "C" {
775    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingtotalassetsize?language=objc)
776    pub static kCTFontDescriptorMatchingTotalAssetSize: &'static CFString;
777}
778
779extern "C" {
780    /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingerror?language=objc)
781    pub static kCTFontDescriptorMatchingError: &'static CFString;
782}
783
784/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontdescriptorprogresshandler?language=objc)
785#[cfg(feature = "block2")]
786pub type CTFontDescriptorProgressHandler =
787    *mut block2::Block<dyn Fn(CTFontDescriptorMatchingState, NonNull<CFDictionary>) -> bool>;
788
789extern "C-unwind" {
790    #[cfg(feature = "block2")]
791    pub fn CTFontDescriptorMatchFontDescriptorsWithProgressHandler(
792        descriptors: &CFArray,
793        mandatory_attributes: Option<&CFSet>,
794        progress_block: CTFontDescriptorProgressHandler,
795    ) -> bool;
796}
797
798/// Returns the attributes dictionary of the font descriptor.
799///
800///
801/// Parameter `descriptor`: The font descriptor reference.
802///
803///
804/// 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.
805#[inline]
806pub unsafe extern "C-unwind" fn CTFontDescriptorCopyAttributes(
807    descriptor: &CTFontDescriptor,
808) -> CFRetained<CFDictionary> {
809    extern "C-unwind" {
810        fn CTFontDescriptorCopyAttributes(
811            descriptor: &CTFontDescriptor,
812        ) -> Option<NonNull<CFDictionary>>;
813    }
814    let ret = unsafe { CTFontDescriptorCopyAttributes(descriptor) };
815    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
816    unsafe { CFRetained::from_raw(ret) }
817}
818
819/// Returns the value associated with an arbitrary attribute.
820///
821///
822/// Parameter `descriptor`: The font descriptor.
823///
824///
825/// Parameter `attribute`: The requested attribute.
826///
827///
828/// 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.
829#[inline]
830pub unsafe extern "C-unwind" fn CTFontDescriptorCopyAttribute(
831    descriptor: &CTFontDescriptor,
832    attribute: &CFString,
833) -> Option<CFRetained<CFType>> {
834    extern "C-unwind" {
835        fn CTFontDescriptorCopyAttribute(
836            descriptor: &CTFontDescriptor,
837            attribute: &CFString,
838        ) -> Option<NonNull<CFType>>;
839    }
840    let ret = unsafe { CTFontDescriptorCopyAttribute(descriptor, attribute) };
841    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
842}
843
844/// function    CTFontDescriptorCopyLocalizedAttribute
845///
846/// Returns a localized value for the requested attribute if available.
847///
848///
849/// 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.
850///
851///
852/// Parameter `descriptor`: The font descriptor reference.
853///
854///
855/// Parameter `attribute`: The requested font attribute.
856///
857///
858/// Parameter `language`: If non-NULL, this will be receive a retained reference to the matched language. The language identifier will conform to UTS #35.
859/// If CoreText can supply its own localized string where the font cannot, this value will be NULL.
860///
861///
862/// 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.
863#[inline]
864pub unsafe extern "C-unwind" fn CTFontDescriptorCopyLocalizedAttribute(
865    descriptor: &CTFontDescriptor,
866    attribute: &CFString,
867    language: *mut *const CFString,
868) -> Option<CFRetained<CFType>> {
869    extern "C-unwind" {
870        fn CTFontDescriptorCopyLocalizedAttribute(
871            descriptor: &CTFontDescriptor,
872            attribute: &CFString,
873            language: *mut *const CFString,
874        ) -> Option<NonNull<CFType>>;
875    }
876    let ret = unsafe { CTFontDescriptorCopyLocalizedAttribute(descriptor, attribute, language) };
877    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
878}