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///
15/// This is toll-free bridged with `NSFontDescriptor`.
16#[doc(alias = "CTFontDescriptorRef")]
17#[repr(C)]
18pub struct CTFontDescriptor {
19 inner: [u8; 0],
20 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
21}
22
23cf_type!(
24 unsafe impl CTFontDescriptor {}
25);
26#[cfg(feature = "objc2")]
27cf_objc2_type!(
28 unsafe impl RefEncode<"__CTFontDescriptor"> for CTFontDescriptor {}
29);
30
31unsafe impl ConcreteType for CTFontDescriptor {
32 /// Returns the type identifier for Core Text font descriptor
33 /// references.
34 ///
35 /// Returns: The identifier for the opaque type CTFontDescriptorRef.
36 #[doc(alias = "CTFontDescriptorGetTypeID")]
37 #[inline]
38 fn type_id() -> CFTypeID {
39 extern "C-unwind" {
40 fn CTFontDescriptorGetTypeID() -> CFTypeID;
41 }
42 unsafe { CTFontDescriptorGetTypeID() }
43 }
44}
45
46extern "C" {
47 /// kCTFontURLAttribute
48 ///
49 /// The font URL.
50 ///
51 /// This is the key for accessing the font URL from the font descriptor. The value associated with this key is a CFURLRef.
52 ///
53 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonturlattribute?language=objc)
54 pub static kCTFontURLAttribute: &'static CFString;
55}
56
57extern "C" {
58 /// kCTFontNameAttribute
59 ///
60 /// The PostScript name.
61 ///
62 /// 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.
63 ///
64 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontnameattribute?language=objc)
65 pub static kCTFontNameAttribute: &'static CFString;
66}
67
68extern "C" {
69 /// kCTFontDisplayNameAttribute
70 ///
71 /// The display name.
72 ///
73 /// 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.
74 ///
75 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdisplaynameattribute?language=objc)
76 pub static kCTFontDisplayNameAttribute: &'static CFString;
77}
78
79extern "C" {
80 /// kCTFontFamilyNameAttribute
81 ///
82 /// The family name.
83 ///
84 /// This is the key for accessing the family name from the font descriptor. The value associated with this key is a CFStringRef.
85 ///
86 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfamilynameattribute?language=objc)
87 pub static kCTFontFamilyNameAttribute: &'static CFString;
88}
89
90extern "C" {
91 /// kCTFontStyleNameAttribute
92 ///
93 /// The style name.
94 ///
95 /// 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.
96 ///
97 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontstylenameattribute?language=objc)
98 pub static kCTFontStyleNameAttribute: &'static CFString;
99}
100
101extern "C" {
102 /// kCTFontTraitsAttribute
103 ///
104 /// The font traits dictionary.
105 ///
106 /// 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.
107 ///
108 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttraitsattribute?language=objc)
109 pub static kCTFontTraitsAttribute: &'static CFString;
110}
111
112extern "C" {
113 /// kCTFontVariationAttribute
114 ///
115 /// The font variation dictionary.
116 ///
117 /// 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.
118 ///
119 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationattribute?language=objc)
120 pub static kCTFontVariationAttribute: &'static CFString;
121}
122
123extern "C" {
124 /// kCTFontVariationAxesAttribute
125 ///
126 /// 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.
127 /// Unlike the result of CTFontCopyVariationAxes(), kCTFontVariationAxisNameKey values for this attribute are not localized.
128 /// Before macOS 13.0 and iOS 16.0 this attribute is not accurate and CTFontCopyVariationAxes() should be used instead.
129 ///
130 ///
131 /// See also: CTFontCopyVariationAxes
132 ///
133 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationaxesattribute?language=objc)
134 pub static kCTFontVariationAxesAttribute: &'static CFString;
135}
136
137extern "C" {
138 /// kCTFontSizeAttribute
139 ///
140 /// The font point size.
141 ///
142 /// 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.
143 ///
144 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontsizeattribute?language=objc)
145 pub static kCTFontSizeAttribute: &'static CFString;
146}
147
148extern "C" {
149 /// kCTFontMatrixAttribute
150 ///
151 /// The font transformation matrix.
152 ///
153 /// 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.
154 ///
155 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontmatrixattribute?language=objc)
156 pub static kCTFontMatrixAttribute: &'static CFString;
157}
158
159extern "C" {
160 /// kCTFontCascadeListAttribute
161 ///
162 /// The font cascade list.
163 ///
164 /// 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.
165 ///
166 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontcascadelistattribute?language=objc)
167 pub static kCTFontCascadeListAttribute: &'static CFString;
168}
169
170extern "C" {
171 /// kCTFontCharacterSetAttribute
172 ///
173 /// The font Unicode character coverage set.
174 ///
175 /// 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.
176 ///
177 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontcharactersetattribute?language=objc)
178 pub static kCTFontCharacterSetAttribute: &'static CFString;
179}
180
181extern "C" {
182 /// kCTFontLanguagesAttribute
183 ///
184 /// The list of supported languages.
185 ///
186 /// 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.
187 ///
188 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontlanguagesattribute?language=objc)
189 pub static kCTFontLanguagesAttribute: &'static CFString;
190}
191
192extern "C" {
193 /// kCTFontBaselineAdjustAttribute
194 ///
195 /// The baseline adjustment to apply to font metrics.
196 ///
197 /// 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.
198 ///
199 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontbaselineadjustattribute?language=objc)
200 pub static kCTFontBaselineAdjustAttribute: &'static CFString;
201}
202
203extern "C" {
204 /// kCTFontMacintoshEncodingsAttribute
205 ///
206 /// The Macintosh encodings (legacy script codes).
207 ///
208 /// The value associated with this key is a CFNumberRef containing a bitfield of the script codes in
209 /// <CoreText
210 /// /SFNTTypes.h>; bit 0 corresponds to kFontRomanScript, and so on. This attribute is provided for legacy compatibility.
211 ///
212 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontmacintoshencodingsattribute?language=objc)
213 pub static kCTFontMacintoshEncodingsAttribute: &'static CFString;
214}
215
216extern "C" {
217 /// kCTFontFeaturesAttribute
218 ///
219 /// The array of font features.
220 ///
221 /// 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
222 /// <CoreText
223 /// /CTFont.h>.
224 /// Unlike the result of CTFontCopyFeatures(), this attribute does not contain localized names.
225 ///
226 ///
227 /// See also: CTFontCopyFeatures
228 ///
229 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturesattribute?language=objc)
230 pub static kCTFontFeaturesAttribute: &'static CFString;
231}
232
233extern "C" {
234 /// kCTFontFeatureSettingsAttribute
235 ///
236 /// The array of typographic feature settings.
237 ///
238 /// 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.
239 /// An AAT setting dictionary contains a tuple of a kCTFontFeatureTypeIdentifierKey key-value pair and a kCTFontFeatureSelectorIdentifierKey key-value pair.
240 /// An OpenType setting dictionary contains a tuple of a kCTFontOpenTypeFeatureTag key-value pair and a kCTFontOpenTypeFeatureValue key-value pair.
241 ///
242 /// Starting with OS X 10.10 and iOS 8.0, settings are also accepted (but not returned) in the following simplified forms:
243 /// An OpenType setting can be either an array pair of tag string and value number, or a tag string on its own. For example:
244 /// @
245 /// [
246 /// "
247 /// c2sc", @1 ] or simply @"c2sc". An unspecified value enables the feature and a value of zero disables it.
248 /// An AAT setting can be specified as an array pair of type and selector numbers. For example:
249 /// @
250 /// [
251 /// @
252 /// (kUpperCaseType),
253 /// @
254 /// (kUpperCaseSmallCapsSelector) ].
255 ///
256 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturesettingsattribute?language=objc)
257 pub static kCTFontFeatureSettingsAttribute: &'static CFString;
258}
259
260extern "C" {
261 /// kCTFontFixedAdvanceAttribute
262 ///
263 /// Specifies advance width.
264 ///
265 /// 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.
266 ///
267 /// 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.
268 ///
269 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfixedadvanceattribute?language=objc)
270 pub static kCTFontFixedAdvanceAttribute: &'static CFString;
271}
272
273extern "C" {
274 /// kCTFontOrientationAttribute
275 ///
276 /// The orientation attribute.
277 ///
278 /// 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.
279 ///
280 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontorientationattribute?language=objc)
281 pub static kCTFontOrientationAttribute: &'static CFString;
282}
283
284/// Specifies the intended rendering orientation of the font for obtaining glyph metrics.
285///
286/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontorientation?language=objc)
287// NS_ENUM
288#[repr(transparent)]
289#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
290pub struct CTFontOrientation(pub u32);
291impl CTFontOrientation {
292 #[doc(alias = "kCTFontOrientationDefault")]
293 pub const Default: Self = Self(0);
294 #[doc(alias = "kCTFontOrientationHorizontal")]
295 pub const Horizontal: Self = Self(1);
296 #[doc(alias = "kCTFontOrientationVertical")]
297 pub const Vertical: Self = Self(2);
298 #[deprecated = "Deprecated"]
299 pub const kCTFontDefaultOrientation: Self = Self(CTFontOrientation::Default.0);
300 #[deprecated = "Deprecated"]
301 pub const kCTFontHorizontalOrientation: Self = Self(CTFontOrientation::Horizontal.0);
302 #[deprecated = "Deprecated"]
303 pub const kCTFontVerticalOrientation: Self = Self(CTFontOrientation::Vertical.0);
304}
305
306#[cfg(feature = "objc2")]
307unsafe impl Encode for CTFontOrientation {
308 const ENCODING: Encoding = u32::ENCODING;
309}
310
311#[cfg(feature = "objc2")]
312unsafe impl RefEncode for CTFontOrientation {
313 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
314}
315
316extern "C" {
317 /// kCTFontFormatAttribute
318 ///
319 /// Specifies the recognized format of the font.
320 ///
321 /// 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.
322 ///
323 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontformatattribute?language=objc)
324 pub static kCTFontFormatAttribute: &'static CFString;
325}
326
327/// The font is not a recognized format
328///
329/// The font is an OpenType format containing PostScript data
330///
331/// The font is an OpenType format containing TrueType data
332///
333/// The font is a recognized TrueType format
334///
335/// The font is a recognized PostScript format
336///
337/// The font is a bitmap only format
338///
339/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontformat?language=objc)
340// NS_ENUM
341#[repr(transparent)]
342#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
343pub struct CTFontFormat(pub u32);
344impl CTFontFormat {
345 #[doc(alias = "kCTFontFormatUnrecognized")]
346 pub const Unrecognized: Self = Self(0);
347 #[doc(alias = "kCTFontFormatOpenTypePostScript")]
348 pub const OpenTypePostScript: Self = Self(1);
349 #[doc(alias = "kCTFontFormatOpenTypeTrueType")]
350 pub const OpenTypeTrueType: Self = Self(2);
351 #[doc(alias = "kCTFontFormatTrueType")]
352 pub const TrueType: Self = Self(3);
353 #[doc(alias = "kCTFontFormatPostScript")]
354 pub const PostScript: Self = Self(4);
355 #[doc(alias = "kCTFontFormatBitmap")]
356 pub const Bitmap: Self = Self(5);
357}
358
359#[cfg(feature = "objc2")]
360unsafe impl Encode for CTFontFormat {
361 const ENCODING: Encoding = u32::ENCODING;
362}
363
364#[cfg(feature = "objc2")]
365unsafe impl RefEncode for CTFontFormat {
366 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
367}
368
369extern "C" {
370 /// kCTFontRegistrationScopeAttribute
371 ///
372 /// Specifies the font descriptor's registration scope.
373 ///
374 /// 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.
375 ///
376 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontregistrationscopeattribute?language=objc)
377 pub static kCTFontRegistrationScopeAttribute: &'static CFString;
378}
379
380extern "C" {
381 /// kCTFontPriorityAttribute
382 ///
383 /// The font descriptors priority when resolving duplicates and sorting match results.
384 ///
385 /// 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.
386 ///
387 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpriorityattribute?language=objc)
388 pub static kCTFontPriorityAttribute: &'static CFString;
389}
390
391/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritysystem?language=objc)
392pub const kCTFontPrioritySystem: c_uint = 10000;
393/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritynetwork?language=objc)
394pub const kCTFontPriorityNetwork: c_uint = 20000;
395/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritycomputer?language=objc)
396pub const kCTFontPriorityComputer: c_uint = 30000;
397/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpriorityuser?language=objc)
398pub const kCTFontPriorityUser: c_uint = 40000;
399/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontprioritydynamic?language=objc)
400pub const kCTFontPriorityDynamic: c_uint = 50000;
401/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpriorityprocess?language=objc)
402pub const kCTFontPriorityProcess: c_uint = 60000;
403
404/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontpriority?language=objc)
405pub type CTFontPriority = u32;
406
407extern "C" {
408 /// kCTFontEnabledAttribute
409 ///
410 /// The font enabled state.
411 ///
412 /// The value associated with this key is a CFBoolean. Unregistered font descriptors will return NULL, which is equivalent to false.
413 ///
414 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontenabledattribute?language=objc)
415 pub static kCTFontEnabledAttribute: &'static CFString;
416}
417
418extern "C" {
419 /// kCTFontDownloadableAttribute
420 ///
421 /// The font downloadable state.
422 ///
423 /// 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.
424 ///
425 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdownloadableattribute?language=objc)
426 pub static kCTFontDownloadableAttribute: &'static CFString;
427}
428
429extern "C" {
430 /// kCTFontDownloadedAttribute
431 ///
432 /// The download state.
433 ///
434 /// 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.)
435 ///
436 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdownloadedattribute?language=objc)
437 pub static kCTFontDownloadedAttribute: &'static CFString;
438}
439
440extern "C" {
441 /// kCTFontOpticalSizeAttribute
442 ///
443 /// The point size at which this font is intended to be used.
444 ///
445 /// 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.
446 ///
447 /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontopticalsizeattribute?language=objc)
448 pub static kCTFontOpticalSizeAttribute: &'static CFString;
449}
450
451impl CTFontDescriptor {
452 /// Creates a new font descriptor with the provided PostScript name and size.
453 ///
454 ///
455 /// 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.
456 ///
457 ///
458 /// Parameter `size`: The point size. If 0.0, the kCTFontSizeAttribute will be omitted from the font descriptor.
459 ///
460 ///
461 /// Returns: This function creates a new font descriptor reference with the given PostScript name and point size.
462 ///
463 ///
464 /// 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.
465 #[doc(alias = "CTFontDescriptorCreateWithNameAndSize")]
466 #[inline]
467 pub unsafe fn with_name_and_size(
468 name: &CFString,
469 size: CGFloat,
470 ) -> CFRetained<CTFontDescriptor> {
471 extern "C-unwind" {
472 fn CTFontDescriptorCreateWithNameAndSize(
473 name: &CFString,
474 size: CGFloat,
475 ) -> Option<NonNull<CTFontDescriptor>>;
476 }
477 let ret = unsafe { CTFontDescriptorCreateWithNameAndSize(name, size) };
478 let ret =
479 ret.expect("function was marked as returning non-null, but actually returned NULL");
480 unsafe { CFRetained::from_raw(ret) }
481 }
482
483 /// Creates a new font descriptor reference from a dictionary of attributes.
484 ///
485 ///
486 /// Parameter `attributes`: A CFDictionaryRef of arbitrary attributes.
487 ///
488 ///
489 /// 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).
490 ///
491 /// # Safety
492 ///
493 /// `attributes` generics must be of the correct type.
494 #[doc(alias = "CTFontDescriptorCreateWithAttributes")]
495 #[inline]
496 pub unsafe fn with_attributes(attributes: &CFDictionary) -> CFRetained<CTFontDescriptor> {
497 extern "C-unwind" {
498 fn CTFontDescriptorCreateWithAttributes(
499 attributes: &CFDictionary,
500 ) -> Option<NonNull<CTFontDescriptor>>;
501 }
502 let ret = unsafe { CTFontDescriptorCreateWithAttributes(attributes) };
503 let ret =
504 ret.expect("function was marked as returning non-null, but actually returned NULL");
505 unsafe { CFRetained::from_raw(ret) }
506 }
507
508 /// Creates a copy of the original font descriptor with new attributes.
509 ///
510 ///
511 /// Parameter `original`: The original font descriptor reference.
512 ///
513 ///
514 /// Parameter `attributes`: A CFDictionaryRef of arbitrary attributes.
515 ///
516 ///
517 /// 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.
518 /// 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
519 /// @
520 /// { (id)kCTFontFeatureTypeIdentifierKey:
521 /// @
522 /// (kLigaturesType), (id)kCTFontFeatureSelectorIdentifierKey: (id)kCFNull } means clear the kLigatureType feature set in the original font descriptor. An element like
523 /// @
524 /// [
525 /// "
526 /// liga", (id)kCFNull ] will have the same effect.
527 ///
528 ///
529 /// See also: kCTFontFeatureSettingsAttribute
530 ///
531 /// # Safety
532 ///
533 /// `attributes` generics must be of the correct type.
534 #[doc(alias = "CTFontDescriptorCreateCopyWithAttributes")]
535 #[inline]
536 pub unsafe fn copy_with_attributes(
537 &self,
538 attributes: &CFDictionary,
539 ) -> CFRetained<CTFontDescriptor> {
540 extern "C-unwind" {
541 fn CTFontDescriptorCreateCopyWithAttributes(
542 original: &CTFontDescriptor,
543 attributes: &CFDictionary,
544 ) -> Option<NonNull<CTFontDescriptor>>;
545 }
546 let ret = unsafe { CTFontDescriptorCreateCopyWithAttributes(self, attributes) };
547 let ret =
548 ret.expect("function was marked as returning non-null, but actually returned NULL");
549 unsafe { CFRetained::from_raw(ret) }
550 }
551
552 /// Returns a new font descriptor in the specified family based on the traits of the original descriptor.
553 ///
554 ///
555 /// Parameter `original`: The original font descriptor reference.
556 ///
557 ///
558 /// Parameter `family`: The name of the desired family.
559 ///
560 ///
561 /// Returns: Returns a new font reference with the original traits in the given family, or NULL if none found in the system.
562 #[doc(alias = "CTFontDescriptorCreateCopyWithFamily")]
563 #[inline]
564 pub unsafe fn copy_with_family(
565 &self,
566 family: &CFString,
567 ) -> Option<CFRetained<CTFontDescriptor>> {
568 extern "C-unwind" {
569 fn CTFontDescriptorCreateCopyWithFamily(
570 original: &CTFontDescriptor,
571 family: &CFString,
572 ) -> Option<NonNull<CTFontDescriptor>>;
573 }
574 let ret = unsafe { CTFontDescriptorCreateCopyWithFamily(self, family) };
575 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
576 }
577
578 /// Returns a new font descriptor based on the original descriptor having the specified symbolic traits.
579 ///
580 ///
581 /// Parameter `original`: The original font descriptor reference.
582 ///
583 ///
584 /// 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.
585 ///
586 ///
587 /// Parameter `symTraitMask`: The mask bits of the symbolic traits. This bitfield is used to indicate the traits that should be changed.
588 ///
589 ///
590 /// Returns: Returns a new font descriptor reference in the same family with the given symbolic traits, or NULL if none found in the system.
591 #[doc(alias = "CTFontDescriptorCreateCopyWithSymbolicTraits")]
592 #[cfg(feature = "CTFontTraits")]
593 #[inline]
594 pub unsafe fn copy_with_symbolic_traits(
595 &self,
596 sym_trait_value: CTFontSymbolicTraits,
597 sym_trait_mask: CTFontSymbolicTraits,
598 ) -> Option<CFRetained<CTFontDescriptor>> {
599 extern "C-unwind" {
600 fn CTFontDescriptorCreateCopyWithSymbolicTraits(
601 original: &CTFontDescriptor,
602 sym_trait_value: CTFontSymbolicTraits,
603 sym_trait_mask: CTFontSymbolicTraits,
604 ) -> Option<NonNull<CTFontDescriptor>>;
605 }
606 let ret = unsafe {
607 CTFontDescriptorCreateCopyWithSymbolicTraits(self, sym_trait_value, sym_trait_mask)
608 };
609 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
610 }
611
612 /// Creates a copy of the original font descriptor with a new variation instance.
613 ///
614 ///
615 /// Parameter `original`: The original font descriptor reference.
616 ///
617 ///
618 /// Parameter `variationIdentifier`: The variation axis identifier. This is the four character code of the variation axis as a CFNumberRef.
619 ///
620 ///
621 /// Parameter `variationValue`: The value corresponding with the variation instance.
622 ///
623 ///
624 /// 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.
625 #[doc(alias = "CTFontDescriptorCreateCopyWithVariation")]
626 #[inline]
627 pub unsafe fn copy_with_variation(
628 &self,
629 variation_identifier: &CFNumber,
630 variation_value: CGFloat,
631 ) -> CFRetained<CTFontDescriptor> {
632 extern "C-unwind" {
633 fn CTFontDescriptorCreateCopyWithVariation(
634 original: &CTFontDescriptor,
635 variation_identifier: &CFNumber,
636 variation_value: CGFloat,
637 ) -> Option<NonNull<CTFontDescriptor>>;
638 }
639 let ret = unsafe {
640 CTFontDescriptorCreateCopyWithVariation(self, variation_identifier, variation_value)
641 };
642 let ret =
643 ret.expect("function was marked as returning non-null, but actually returned NULL");
644 unsafe { CFRetained::from_raw(ret) }
645 }
646
647 /// Copies a font descriptor with new feature setting.
648 ///
649 ///
650 /// This is a convenience method to more easily toggle the state of individual features.
651 ///
652 ///
653 /// Parameter `original`: The original font descriptor reference.
654 ///
655 ///
656 /// Parameter `featureTypeIdentifier`: The feature type identifier.
657 ///
658 ///
659 /// Parameter `featureSelectorIdentifier`: The feature selector identifier.
660 ///
661 ///
662 /// Returns: A copy of the original font descriptor modified with the given feature settings.
663 ///
664 ///
665 /// See also: CTFontDescriptorCreateCopyWithAttributes
666 ///
667 /// See also: kCTFontFeatureSettingsAttribute
668 #[doc(alias = "CTFontDescriptorCreateCopyWithFeature")]
669 #[inline]
670 pub unsafe fn copy_with_feature(
671 &self,
672 feature_type_identifier: &CFNumber,
673 feature_selector_identifier: &CFNumber,
674 ) -> CFRetained<CTFontDescriptor> {
675 extern "C-unwind" {
676 fn CTFontDescriptorCreateCopyWithFeature(
677 original: &CTFontDescriptor,
678 feature_type_identifier: &CFNumber,
679 feature_selector_identifier: &CFNumber,
680 ) -> Option<NonNull<CTFontDescriptor>>;
681 }
682 let ret = unsafe {
683 CTFontDescriptorCreateCopyWithFeature(
684 self,
685 feature_type_identifier,
686 feature_selector_identifier,
687 )
688 };
689 let ret =
690 ret.expect("function was marked as returning non-null, but actually returned NULL");
691 unsafe { CFRetained::from_raw(ret) }
692 }
693
694 /// Returns an array of font normalized font descriptors matching the provided descriptor.
695 ///
696 ///
697 /// Parameter `descriptor`: The font descriptor reference.
698 ///
699 ///
700 /// Parameter `mandatoryAttributes`: A set of attribute keys which are required to be identically matched in any returned font descriptors. Optional.
701 ///
702 ///
703 /// 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.
704 ///
705 /// # Safety
706 ///
707 /// `mandatory_attributes` generic must be of the correct type.
708 #[doc(alias = "CTFontDescriptorCreateMatchingFontDescriptors")]
709 #[inline]
710 pub unsafe fn matching_font_descriptors(
711 &self,
712 mandatory_attributes: Option<&CFSet>,
713 ) -> Option<CFRetained<CFArray>> {
714 extern "C-unwind" {
715 fn CTFontDescriptorCreateMatchingFontDescriptors(
716 descriptor: &CTFontDescriptor,
717 mandatory_attributes: Option<&CFSet>,
718 ) -> Option<NonNull<CFArray>>;
719 }
720 let ret =
721 unsafe { CTFontDescriptorCreateMatchingFontDescriptors(self, mandatory_attributes) };
722 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
723 }
724
725 /// Returns an the single preferred matching font descriptor based on the original descriptor and system precedence.
726 ///
727 ///
728 /// Parameter `descriptor`: The font descriptor reference.
729 ///
730 ///
731 /// Parameter `mandatoryAttributes`: A set of attribute keys which are required to be identically matched in any returned font descriptors. Optional.
732 ///
733 ///
734 /// Returns: This function returns a retained normalized font descriptor matching the attributes present in descriptor. The original descriptor may be returned in normalized form.
735 ///
736 /// # Safety
737 ///
738 /// `mandatory_attributes` generic must be of the correct type.
739 #[doc(alias = "CTFontDescriptorCreateMatchingFontDescriptor")]
740 #[inline]
741 pub unsafe fn matching_font_descriptor(
742 &self,
743 mandatory_attributes: Option<&CFSet>,
744 ) -> Option<CFRetained<CTFontDescriptor>> {
745 extern "C-unwind" {
746 fn CTFontDescriptorCreateMatchingFontDescriptor(
747 descriptor: &CTFontDescriptor,
748 mandatory_attributes: Option<&CFSet>,
749 ) -> Option<NonNull<CTFontDescriptor>>;
750 }
751 let ret =
752 unsafe { CTFontDescriptorCreateMatchingFontDescriptor(self, mandatory_attributes) };
753 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
754 }
755}
756
757/// Progress state
758///
759/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontdescriptormatchingstate?language=objc)
760// NS_ENUM
761#[repr(transparent)]
762#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
763pub struct CTFontDescriptorMatchingState(pub u32);
764impl CTFontDescriptorMatchingState {
765 #[doc(alias = "kCTFontDescriptorMatchingDidBegin")]
766 pub const DidBegin: Self = Self(0);
767 #[doc(alias = "kCTFontDescriptorMatchingDidFinish")]
768 pub const DidFinish: Self = Self(1);
769 #[doc(alias = "kCTFontDescriptorMatchingWillBeginQuerying")]
770 pub const WillBeginQuerying: Self = Self(2);
771 #[doc(alias = "kCTFontDescriptorMatchingStalled")]
772 pub const Stalled: Self = Self(3);
773 #[doc(alias = "kCTFontDescriptorMatchingWillBeginDownloading")]
774 pub const WillBeginDownloading: Self = Self(4);
775 #[doc(alias = "kCTFontDescriptorMatchingDownloading")]
776 pub const Downloading: Self = Self(5);
777 #[doc(alias = "kCTFontDescriptorMatchingDidFinishDownloading")]
778 pub const DidFinishDownloading: Self = Self(6);
779 #[doc(alias = "kCTFontDescriptorMatchingDidMatch")]
780 pub const DidMatch: Self = Self(7);
781 #[doc(alias = "kCTFontDescriptorMatchingDidFailWithError")]
782 pub const DidFailWithError: Self = Self(8);
783}
784
785#[cfg(feature = "objc2")]
786unsafe impl Encode for CTFontDescriptorMatchingState {
787 const ENCODING: Encoding = u32::ENCODING;
788}
789
790#[cfg(feature = "objc2")]
791unsafe impl RefEncode for CTFontDescriptorMatchingState {
792 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
793}
794
795extern "C" {
796 /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingsourcedescriptor?language=objc)
797 pub static kCTFontDescriptorMatchingSourceDescriptor: &'static CFString;
798}
799
800extern "C" {
801 /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingdescriptors?language=objc)
802 pub static kCTFontDescriptorMatchingDescriptors: &'static CFString;
803}
804
805extern "C" {
806 /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingresult?language=objc)
807 pub static kCTFontDescriptorMatchingResult: &'static CFString;
808}
809
810extern "C" {
811 /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingpercentage?language=objc)
812 pub static kCTFontDescriptorMatchingPercentage: &'static CFString;
813}
814
815extern "C" {
816 /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingcurrentassetsize?language=objc)
817 pub static kCTFontDescriptorMatchingCurrentAssetSize: &'static CFString;
818}
819
820extern "C" {
821 /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingtotaldownloadedsize?language=objc)
822 pub static kCTFontDescriptorMatchingTotalDownloadedSize: &'static CFString;
823}
824
825extern "C" {
826 /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingtotalassetsize?language=objc)
827 pub static kCTFontDescriptorMatchingTotalAssetSize: &'static CFString;
828}
829
830extern "C" {
831 /// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptormatchingerror?language=objc)
832 pub static kCTFontDescriptorMatchingError: &'static CFString;
833}
834
835/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontdescriptorprogresshandler?language=objc)
836#[cfg(feature = "block2")]
837pub type CTFontDescriptorProgressHandler =
838 *mut block2::DynBlock<dyn Fn(CTFontDescriptorMatchingState, NonNull<CFDictionary>) -> bool>;
839
840impl CTFontDescriptor {
841 /// # Safety
842 ///
843 /// - `descriptors` generic must be of the correct type.
844 /// - `mandatory_attributes` generic must be of the correct type.
845 /// - `progress_block` must be a valid pointer.
846 #[doc(alias = "CTFontDescriptorMatchFontDescriptorsWithProgressHandler")]
847 #[cfg(feature = "block2")]
848 #[inline]
849 pub unsafe fn match_font_descriptors_with_progress_handler(
850 descriptors: &CFArray,
851 mandatory_attributes: Option<&CFSet>,
852 progress_block: CTFontDescriptorProgressHandler,
853 ) -> bool {
854 extern "C-unwind" {
855 fn CTFontDescriptorMatchFontDescriptorsWithProgressHandler(
856 descriptors: &CFArray,
857 mandatory_attributes: Option<&CFSet>,
858 progress_block: CTFontDescriptorProgressHandler,
859 ) -> bool;
860 }
861 unsafe {
862 CTFontDescriptorMatchFontDescriptorsWithProgressHandler(
863 descriptors,
864 mandatory_attributes,
865 progress_block,
866 )
867 }
868 }
869
870 /// Returns the attributes dictionary of the font descriptor.
871 ///
872 ///
873 /// Parameter `descriptor`: The font descriptor reference.
874 ///
875 ///
876 /// 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.
877 #[doc(alias = "CTFontDescriptorCopyAttributes")]
878 #[inline]
879 pub unsafe fn attributes(&self) -> CFRetained<CFDictionary> {
880 extern "C-unwind" {
881 fn CTFontDescriptorCopyAttributes(
882 descriptor: &CTFontDescriptor,
883 ) -> Option<NonNull<CFDictionary>>;
884 }
885 let ret = unsafe { CTFontDescriptorCopyAttributes(self) };
886 let ret =
887 ret.expect("function was marked as returning non-null, but actually returned NULL");
888 unsafe { CFRetained::from_raw(ret) }
889 }
890
891 /// Returns the value associated with an arbitrary attribute.
892 ///
893 ///
894 /// Parameter `descriptor`: The font descriptor.
895 ///
896 ///
897 /// Parameter `attribute`: The requested attribute.
898 ///
899 ///
900 /// 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.
901 #[doc(alias = "CTFontDescriptorCopyAttribute")]
902 #[inline]
903 pub unsafe fn attribute(&self, attribute: &CFString) -> Option<CFRetained<CFType>> {
904 extern "C-unwind" {
905 fn CTFontDescriptorCopyAttribute(
906 descriptor: &CTFontDescriptor,
907 attribute: &CFString,
908 ) -> Option<NonNull<CFType>>;
909 }
910 let ret = unsafe { CTFontDescriptorCopyAttribute(self, attribute) };
911 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
912 }
913
914 /// function CTFontDescriptorCopyLocalizedAttribute
915 ///
916 /// Returns a localized value for the requested attribute if available.
917 ///
918 ///
919 /// 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.
920 ///
921 ///
922 /// Parameter `descriptor`: The font descriptor reference.
923 ///
924 ///
925 /// Parameter `attribute`: The requested font attribute.
926 ///
927 ///
928 /// Parameter `language`: If non-NULL, this will be receive a retained reference to the matched language. The language identifier will conform to UTS #35.
929 /// If CoreText can supply its own localized string where the font cannot, this value will be NULL.
930 ///
931 ///
932 /// 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.
933 ///
934 /// # Safety
935 ///
936 /// `language` must be a valid pointer or null.
937 #[doc(alias = "CTFontDescriptorCopyLocalizedAttribute")]
938 #[inline]
939 pub unsafe fn localized_attribute(
940 &self,
941 attribute: &CFString,
942 language: *mut *const CFString,
943 ) -> Option<CFRetained<CFType>> {
944 extern "C-unwind" {
945 fn CTFontDescriptorCopyLocalizedAttribute(
946 descriptor: &CTFontDescriptor,
947 attribute: &CFString,
948 language: *mut *const CFString,
949 ) -> Option<NonNull<CFType>>;
950 }
951 let ret = unsafe { CTFontDescriptorCopyLocalizedAttribute(self, attribute, language) };
952 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
953 }
954}
955
956#[deprecated = "renamed to `CTFontDescriptor::with_name_and_size`"]
957#[inline]
958pub unsafe extern "C-unwind" fn CTFontDescriptorCreateWithNameAndSize(
959 name: &CFString,
960 size: CGFloat,
961) -> CFRetained<CTFontDescriptor> {
962 extern "C-unwind" {
963 fn CTFontDescriptorCreateWithNameAndSize(
964 name: &CFString,
965 size: CGFloat,
966 ) -> Option<NonNull<CTFontDescriptor>>;
967 }
968 let ret = unsafe { CTFontDescriptorCreateWithNameAndSize(name, size) };
969 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
970 unsafe { CFRetained::from_raw(ret) }
971}
972
973#[deprecated = "renamed to `CTFontDescriptor::with_attributes`"]
974#[inline]
975pub unsafe extern "C-unwind" fn CTFontDescriptorCreateWithAttributes(
976 attributes: &CFDictionary,
977) -> CFRetained<CTFontDescriptor> {
978 extern "C-unwind" {
979 fn CTFontDescriptorCreateWithAttributes(
980 attributes: &CFDictionary,
981 ) -> Option<NonNull<CTFontDescriptor>>;
982 }
983 let ret = unsafe { CTFontDescriptorCreateWithAttributes(attributes) };
984 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
985 unsafe { CFRetained::from_raw(ret) }
986}
987
988#[deprecated = "renamed to `CTFontDescriptor::copy_with_attributes`"]
989#[inline]
990pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithAttributes(
991 original: &CTFontDescriptor,
992 attributes: &CFDictionary,
993) -> CFRetained<CTFontDescriptor> {
994 extern "C-unwind" {
995 fn CTFontDescriptorCreateCopyWithAttributes(
996 original: &CTFontDescriptor,
997 attributes: &CFDictionary,
998 ) -> Option<NonNull<CTFontDescriptor>>;
999 }
1000 let ret = unsafe { CTFontDescriptorCreateCopyWithAttributes(original, attributes) };
1001 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
1002 unsafe { CFRetained::from_raw(ret) }
1003}
1004
1005#[deprecated = "renamed to `CTFontDescriptor::copy_with_family`"]
1006#[inline]
1007pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithFamily(
1008 original: &CTFontDescriptor,
1009 family: &CFString,
1010) -> Option<CFRetained<CTFontDescriptor>> {
1011 extern "C-unwind" {
1012 fn CTFontDescriptorCreateCopyWithFamily(
1013 original: &CTFontDescriptor,
1014 family: &CFString,
1015 ) -> Option<NonNull<CTFontDescriptor>>;
1016 }
1017 let ret = unsafe { CTFontDescriptorCreateCopyWithFamily(original, family) };
1018 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1019}
1020
1021#[cfg(feature = "CTFontTraits")]
1022#[deprecated = "renamed to `CTFontDescriptor::copy_with_symbolic_traits`"]
1023#[inline]
1024pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithSymbolicTraits(
1025 original: &CTFontDescriptor,
1026 sym_trait_value: CTFontSymbolicTraits,
1027 sym_trait_mask: CTFontSymbolicTraits,
1028) -> Option<CFRetained<CTFontDescriptor>> {
1029 extern "C-unwind" {
1030 fn CTFontDescriptorCreateCopyWithSymbolicTraits(
1031 original: &CTFontDescriptor,
1032 sym_trait_value: CTFontSymbolicTraits,
1033 sym_trait_mask: CTFontSymbolicTraits,
1034 ) -> Option<NonNull<CTFontDescriptor>>;
1035 }
1036 let ret = unsafe {
1037 CTFontDescriptorCreateCopyWithSymbolicTraits(original, sym_trait_value, sym_trait_mask)
1038 };
1039 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1040}
1041
1042#[deprecated = "renamed to `CTFontDescriptor::copy_with_variation`"]
1043#[inline]
1044pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithVariation(
1045 original: &CTFontDescriptor,
1046 variation_identifier: &CFNumber,
1047 variation_value: CGFloat,
1048) -> CFRetained<CTFontDescriptor> {
1049 extern "C-unwind" {
1050 fn CTFontDescriptorCreateCopyWithVariation(
1051 original: &CTFontDescriptor,
1052 variation_identifier: &CFNumber,
1053 variation_value: CGFloat,
1054 ) -> Option<NonNull<CTFontDescriptor>>;
1055 }
1056 let ret = unsafe {
1057 CTFontDescriptorCreateCopyWithVariation(original, variation_identifier, variation_value)
1058 };
1059 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
1060 unsafe { CFRetained::from_raw(ret) }
1061}
1062
1063#[deprecated = "renamed to `CTFontDescriptor::copy_with_feature`"]
1064#[inline]
1065pub unsafe extern "C-unwind" fn CTFontDescriptorCreateCopyWithFeature(
1066 original: &CTFontDescriptor,
1067 feature_type_identifier: &CFNumber,
1068 feature_selector_identifier: &CFNumber,
1069) -> CFRetained<CTFontDescriptor> {
1070 extern "C-unwind" {
1071 fn CTFontDescriptorCreateCopyWithFeature(
1072 original: &CTFontDescriptor,
1073 feature_type_identifier: &CFNumber,
1074 feature_selector_identifier: &CFNumber,
1075 ) -> Option<NonNull<CTFontDescriptor>>;
1076 }
1077 let ret = unsafe {
1078 CTFontDescriptorCreateCopyWithFeature(
1079 original,
1080 feature_type_identifier,
1081 feature_selector_identifier,
1082 )
1083 };
1084 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
1085 unsafe { CFRetained::from_raw(ret) }
1086}
1087
1088#[deprecated = "renamed to `CTFontDescriptor::matching_font_descriptors`"]
1089#[inline]
1090pub unsafe extern "C-unwind" fn CTFontDescriptorCreateMatchingFontDescriptors(
1091 descriptor: &CTFontDescriptor,
1092 mandatory_attributes: Option<&CFSet>,
1093) -> Option<CFRetained<CFArray>> {
1094 extern "C-unwind" {
1095 fn CTFontDescriptorCreateMatchingFontDescriptors(
1096 descriptor: &CTFontDescriptor,
1097 mandatory_attributes: Option<&CFSet>,
1098 ) -> Option<NonNull<CFArray>>;
1099 }
1100 let ret =
1101 unsafe { CTFontDescriptorCreateMatchingFontDescriptors(descriptor, mandatory_attributes) };
1102 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1103}
1104
1105#[deprecated = "renamed to `CTFontDescriptor::matching_font_descriptor`"]
1106#[inline]
1107pub unsafe extern "C-unwind" fn CTFontDescriptorCreateMatchingFontDescriptor(
1108 descriptor: &CTFontDescriptor,
1109 mandatory_attributes: Option<&CFSet>,
1110) -> Option<CFRetained<CTFontDescriptor>> {
1111 extern "C-unwind" {
1112 fn CTFontDescriptorCreateMatchingFontDescriptor(
1113 descriptor: &CTFontDescriptor,
1114 mandatory_attributes: Option<&CFSet>,
1115 ) -> Option<NonNull<CTFontDescriptor>>;
1116 }
1117 let ret =
1118 unsafe { CTFontDescriptorCreateMatchingFontDescriptor(descriptor, mandatory_attributes) };
1119 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1120}
1121
1122extern "C-unwind" {
1123 #[cfg(feature = "block2")]
1124 #[deprecated = "renamed to `CTFontDescriptor::match_font_descriptors_with_progress_handler`"]
1125 pub fn CTFontDescriptorMatchFontDescriptorsWithProgressHandler(
1126 descriptors: &CFArray,
1127 mandatory_attributes: Option<&CFSet>,
1128 progress_block: CTFontDescriptorProgressHandler,
1129 ) -> bool;
1130}
1131
1132#[deprecated = "renamed to `CTFontDescriptor::attributes`"]
1133#[inline]
1134pub unsafe extern "C-unwind" fn CTFontDescriptorCopyAttributes(
1135 descriptor: &CTFontDescriptor,
1136) -> CFRetained<CFDictionary> {
1137 extern "C-unwind" {
1138 fn CTFontDescriptorCopyAttributes(
1139 descriptor: &CTFontDescriptor,
1140 ) -> Option<NonNull<CFDictionary>>;
1141 }
1142 let ret = unsafe { CTFontDescriptorCopyAttributes(descriptor) };
1143 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
1144 unsafe { CFRetained::from_raw(ret) }
1145}
1146
1147#[deprecated = "renamed to `CTFontDescriptor::attribute`"]
1148#[inline]
1149pub unsafe extern "C-unwind" fn CTFontDescriptorCopyAttribute(
1150 descriptor: &CTFontDescriptor,
1151 attribute: &CFString,
1152) -> Option<CFRetained<CFType>> {
1153 extern "C-unwind" {
1154 fn CTFontDescriptorCopyAttribute(
1155 descriptor: &CTFontDescriptor,
1156 attribute: &CFString,
1157 ) -> Option<NonNull<CFType>>;
1158 }
1159 let ret = unsafe { CTFontDescriptorCopyAttribute(descriptor, attribute) };
1160 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1161}
1162
1163#[deprecated = "renamed to `CTFontDescriptor::localized_attribute`"]
1164#[inline]
1165pub unsafe extern "C-unwind" fn CTFontDescriptorCopyLocalizedAttribute(
1166 descriptor: &CTFontDescriptor,
1167 attribute: &CFString,
1168 language: *mut *const CFString,
1169) -> Option<CFRetained<CFType>> {
1170 extern "C-unwind" {
1171 fn CTFontDescriptorCopyLocalizedAttribute(
1172 descriptor: &CTFontDescriptor,
1173 attribute: &CFString,
1174 language: *mut *const CFString,
1175 ) -> Option<NonNull<CFType>>;
1176 }
1177 let ret = unsafe { CTFontDescriptorCopyLocalizedAttribute(descriptor, attribute, language) };
1178 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1179}