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