objc2_core_text/generated/
CTFont.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#[cfg(feature = "objc2-core-graphics")]
11use objc2_core_graphics::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfont?language=objc)
16#[repr(C)]
17pub struct CTFont {
18    inner: [u8; 0],
19    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22cf_type!(
23    unsafe impl CTFont {}
24);
25#[cfg(feature = "objc2")]
26cf_objc2_type!(
27    unsafe impl RefEncode<"__CTFont"> for CTFont {}
28);
29
30unsafe impl ConcreteType for CTFont {
31    /// Returns the type identifier for Core Text font references.
32    ///
33    /// Returns: The identifier for the opaque type CTFontRef.
34    #[doc(alias = "CTFontGetTypeID")]
35    #[inline]
36    fn type_id() -> CFTypeID {
37        extern "C-unwind" {
38            fn CTFontGetTypeID() -> CFTypeID;
39        }
40        unsafe { CTFontGetTypeID() }
41    }
42}
43
44extern "C" {
45    /// kCTFontCopyrightNameKey
46    ///
47    /// The name specifier for the copyright name.
48    ///
49    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontcopyrightnamekey?language=objc)
50    pub static kCTFontCopyrightNameKey: &'static CFString;
51}
52
53extern "C" {
54    /// kCTFontFamilyNameKey
55    ///
56    /// The name specifier for the family name.
57    ///
58    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfamilynamekey?language=objc)
59    pub static kCTFontFamilyNameKey: &'static CFString;
60}
61
62extern "C" {
63    /// kCTFontSubFamilyNameKey
64    ///
65    /// The name specifier for the subfamily name.
66    ///
67    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontsubfamilynamekey?language=objc)
68    pub static kCTFontSubFamilyNameKey: &'static CFString;
69}
70
71extern "C" {
72    /// kCTFontStyleNameKey
73    ///
74    /// The name specifier for the style name.
75    ///
76    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontstylenamekey?language=objc)
77    pub static kCTFontStyleNameKey: &'static CFString;
78}
79
80extern "C" {
81    /// kCTFontUniqueNameKey
82    ///
83    /// The name specifier for the unique name.
84    ///
85    /// Note that this name is often not unique and should not be
86    /// assumed to be truly unique.
87    ///
88    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontuniquenamekey?language=objc)
89    pub static kCTFontUniqueNameKey: &'static CFString;
90}
91
92extern "C" {
93    /// kCTFontFullNameKey
94    ///
95    /// The name specifier for the full name.
96    ///
97    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfullnamekey?language=objc)
98    pub static kCTFontFullNameKey: &'static CFString;
99}
100
101extern "C" {
102    /// kCTFontVersionNameKey
103    ///
104    /// The name specifier for the version name.
105    ///
106    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontversionnamekey?language=objc)
107    pub static kCTFontVersionNameKey: &'static CFString;
108}
109
110extern "C" {
111    /// kCTFontPostScriptNameKey
112    ///
113    /// The name specifier for the PostScript name.
114    ///
115    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpostscriptnamekey?language=objc)
116    pub static kCTFontPostScriptNameKey: &'static CFString;
117}
118
119extern "C" {
120    /// kCTFontTrademarkNameKey
121    ///
122    /// The name specifier for the trademark name.
123    ///
124    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttrademarknamekey?language=objc)
125    pub static kCTFontTrademarkNameKey: &'static CFString;
126}
127
128extern "C" {
129    /// kCTFontManufacturerNameKey
130    ///
131    /// The name specifier for the manufacturer name.
132    ///
133    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontmanufacturernamekey?language=objc)
134    pub static kCTFontManufacturerNameKey: &'static CFString;
135}
136
137extern "C" {
138    /// kCTFontDesignerNameKey
139    ///
140    /// The name specifier for the designer name.
141    ///
142    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdesignernamekey?language=objc)
143    pub static kCTFontDesignerNameKey: &'static CFString;
144}
145
146extern "C" {
147    /// kCTFontDescriptionNameKey
148    ///
149    /// The name specifier for the description name.
150    ///
151    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdescriptionnamekey?language=objc)
152    pub static kCTFontDescriptionNameKey: &'static CFString;
153}
154
155extern "C" {
156    /// kCTFontVendorURLNameKey
157    ///
158    /// The name specifier for the vendor url name.
159    ///
160    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvendorurlnamekey?language=objc)
161    pub static kCTFontVendorURLNameKey: &'static CFString;
162}
163
164extern "C" {
165    /// kCTFontDesignerURLNameKey
166    ///
167    /// The name specifier for the designer url name.
168    ///
169    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontdesignerurlnamekey?language=objc)
170    pub static kCTFontDesignerURLNameKey: &'static CFString;
171}
172
173extern "C" {
174    /// kCTFontLicenseNameKey
175    ///
176    /// The name specifier for the license name.
177    ///
178    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontlicensenamekey?language=objc)
179    pub static kCTFontLicenseNameKey: &'static CFString;
180}
181
182extern "C" {
183    /// kCTFontLicenseURLNameKey
184    ///
185    /// The name specifier for the license url name.
186    ///
187    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontlicenseurlnamekey?language=objc)
188    pub static kCTFontLicenseURLNameKey: &'static CFString;
189}
190
191extern "C" {
192    /// kCTFontSampleTextNameKey
193    ///
194    /// The name specifier for the sample text name string.
195    ///
196    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontsampletextnamekey?language=objc)
197    pub static kCTFontSampleTextNameKey: &'static CFString;
198}
199
200extern "C" {
201    /// kCTFontPostScriptCIDNameKey
202    ///
203    /// The name specifier for the PostScript CID name.
204    ///
205    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontpostscriptcidnamekey?language=objc)
206    pub static kCTFontPostScriptCIDNameKey: &'static CFString;
207}
208
209impl CTFont {
210    /// Returns a new font reference for the given name.
211    ///
212    ///
213    /// This function uses font descriptor matching so only registered fonts can be returned; see CTFontManager.h for more information. If you are trying to create a system UI font (with name beginning with a "."), you should use CTFontCreateUIFontForLanguage() or appropriate AppKit/UIKit APIs instead.
214    ///
215    ///
216    /// Parameter `name`: The font name for which you wish to create a new font reference. A valid PostScript name is preferred, although other font name types will be matched in a fallback manner. Any font name beginning with a "." is reserved for the system and should not be used here.
217    ///
218    ///
219    /// Parameter `size`: The point size for the font reference. If 0.0 is specified, the default font size of 12.0 will be used.
220    ///
221    ///
222    /// Parameter `matrix`: The transformation matrix for the font. If unspecified, the identity matrix will be used. Optional.
223    ///
224    ///
225    /// Returns: This function will return a CTFontRef that best matches the name provided with size and matrix attributes. The name parameter is the only required parameters, and default values will be used for unspecified parameters. A best match will be found if all parameters cannot be matched identically.
226    #[doc(alias = "CTFontCreateWithName")]
227    #[inline]
228    pub unsafe fn with_name(
229        name: &CFString,
230        size: CGFloat,
231        matrix: *const CGAffineTransform,
232    ) -> CFRetained<CTFont> {
233        extern "C-unwind" {
234            fn CTFontCreateWithName(
235                name: &CFString,
236                size: CGFloat,
237                matrix: *const CGAffineTransform,
238            ) -> Option<NonNull<CTFont>>;
239        }
240        let ret = unsafe { CTFontCreateWithName(name, size, matrix) };
241        let ret =
242            ret.expect("function was marked as returning non-null, but actually returned NULL");
243        unsafe { CFRetained::from_raw(ret) }
244    }
245
246    /// Returns a new font reference that best matches the font descriptor.
247    ///
248    ///
249    /// Parameter `descriptor`: A font descriptor containing attributes that specify the requested font.
250    ///
251    ///
252    /// Parameter `size`: The point size for the font reference. If 0.0 is specified and the font descriptor does not specify the size, the default font size of 12.0 will be used.
253    ///
254    ///
255    /// Parameter `matrix`: The transformation matrix for the font. If unspecified, the identity matrix will be used. Optional.
256    ///
257    ///
258    /// Returns: This function will return a CTFontRef that best matches the attributes provided with the font descriptor. The size and matrix parameters will override any specified in the font descriptor, unless they are unspecified. A best match font will always be returned, and default values will be used for any unspecified.
259    #[doc(alias = "CTFontCreateWithFontDescriptor")]
260    #[cfg(feature = "CTFontDescriptor")]
261    #[inline]
262    pub unsafe fn with_font_descriptor(
263        descriptor: &CTFontDescriptor,
264        size: CGFloat,
265        matrix: *const CGAffineTransform,
266    ) -> CFRetained<CTFont> {
267        extern "C-unwind" {
268            fn CTFontCreateWithFontDescriptor(
269                descriptor: &CTFontDescriptor,
270                size: CGFloat,
271                matrix: *const CGAffineTransform,
272            ) -> Option<NonNull<CTFont>>;
273        }
274        let ret = unsafe { CTFontCreateWithFontDescriptor(descriptor, size, matrix) };
275        let ret =
276            ret.expect("function was marked as returning non-null, but actually returned NULL");
277        unsafe { CFRetained::from_raw(ret) }
278    }
279}
280
281/// Options for descriptor match and font creation.
282///
283/// Prevents automatic font activation from taking place.
284/// This option is available only on macOS and will be deprecated on other platforms in the future.
285///
286/// Prevents automatic font download from taking place.
287///
288/// Font matching will prefer to match Apple system fonts.
289///
290/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontoptions?language=objc)
291// NS_OPTIONS
292#[repr(transparent)]
293#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
294pub struct CTFontOptions(pub CFOptionFlags);
295bitflags::bitflags! {
296    impl CTFontOptions: CFOptionFlags {
297        #[doc(alias = "kCTFontOptionsDefault")]
298        const Default = 0;
299        #[doc(alias = "kCTFontOptionsPreventAutoActivation")]
300        const PreventAutoActivation = 1<<0;
301        #[doc(alias = "kCTFontOptionsPreventAutoDownload")]
302        const PreventAutoDownload = 1<<1;
303        #[doc(alias = "kCTFontOptionsPreferSystemFont")]
304        const PreferSystemFont = 1<<2;
305    }
306}
307
308#[cfg(feature = "objc2")]
309unsafe impl Encode for CTFontOptions {
310    const ENCODING: Encoding = CFOptionFlags::ENCODING;
311}
312
313#[cfg(feature = "objc2")]
314unsafe impl RefEncode for CTFontOptions {
315    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
316}
317
318impl CTFont {
319    /// Returns a new font reference for the given name.
320    ///
321    ///
322    /// This function uses font descriptor matching so only registered fonts can be returned; see CTFontManager.h for more information. If you are trying to create a system UI font (with name beginning with a "."), you should use CTFontCreateUIFontForLanguage() or appropriate AppKit/UIKit APIs instead.
323    ///
324    ///
325    /// Parameter `name`: The font name for which you wish to create a new font reference. A valid PostScript name is preferred, although other font name types will be matched in a fallback manner. Any font name beginning with a "." is reserved for the system and should not be used here.
326    ///
327    ///
328    /// Parameter `size`: The point size for the font reference. If 0.0 is specified, the default font size of 12.0 will be used.
329    ///
330    ///
331    /// Parameter `matrix`: The transformation matrix for the font. If unspecified, the identity matrix will be used. Optional.
332    ///
333    ///
334    /// Parameter `options`: Options flags.
335    ///
336    ///
337    /// Returns: This function will return a CTFontRef that best matches the name provided with size and matrix attributes. The name parameter is the only required parameters, and default values will be used for unspecified parameters. A best match will be found if all parameters cannot be matched identically.
338    #[doc(alias = "CTFontCreateWithNameAndOptions")]
339    #[inline]
340    pub unsafe fn with_name_and_options(
341        name: &CFString,
342        size: CGFloat,
343        matrix: *const CGAffineTransform,
344        options: CTFontOptions,
345    ) -> CFRetained<CTFont> {
346        extern "C-unwind" {
347            fn CTFontCreateWithNameAndOptions(
348                name: &CFString,
349                size: CGFloat,
350                matrix: *const CGAffineTransform,
351                options: CTFontOptions,
352            ) -> Option<NonNull<CTFont>>;
353        }
354        let ret = unsafe { CTFontCreateWithNameAndOptions(name, size, matrix, options) };
355        let ret =
356            ret.expect("function was marked as returning non-null, but actually returned NULL");
357        unsafe { CFRetained::from_raw(ret) }
358    }
359
360    /// Returns a new font reference that best matches the font descriptor.
361    ///
362    ///
363    /// Parameter `descriptor`: A font descriptor containing attributes that specify the requested font.
364    ///
365    ///
366    /// Parameter `size`: The point size for the font reference. If 0.0 is specified, the default font size of 12.0 will be used.
367    ///
368    ///
369    /// Parameter `matrix`: The transformation matrix for the font. If unspecified, the identity matrix will be used. Optional.
370    ///
371    ///
372    /// Parameter `options`: Options flags.
373    ///
374    ///
375    /// Returns: This function will return a CTFontRef that best matches the attributes provided with the font descriptor. The size and matrix parameters will override any specified in the font descriptor, unless they are unspecified. A best match font will always be returned, and default values will be used for any unspecified.
376    #[doc(alias = "CTFontCreateWithFontDescriptorAndOptions")]
377    #[cfg(feature = "CTFontDescriptor")]
378    #[inline]
379    pub unsafe fn with_font_descriptor_and_options(
380        descriptor: &CTFontDescriptor,
381        size: CGFloat,
382        matrix: *const CGAffineTransform,
383        options: CTFontOptions,
384    ) -> CFRetained<CTFont> {
385        extern "C-unwind" {
386            fn CTFontCreateWithFontDescriptorAndOptions(
387                descriptor: &CTFontDescriptor,
388                size: CGFloat,
389                matrix: *const CGAffineTransform,
390                options: CTFontOptions,
391            ) -> Option<NonNull<CTFont>>;
392        }
393        let ret =
394            unsafe { CTFontCreateWithFontDescriptorAndOptions(descriptor, size, matrix, options) };
395        let ret =
396            ret.expect("function was marked as returning non-null, but actually returned NULL");
397        unsafe { CFRetained::from_raw(ret) }
398    }
399}
400
401/// These constants represent the specific user interface purpose to specify for font creation.
402///
403/// Use these constants with CTFontCreateUIFontForLanguage to indicate the intended user interface usage of the font reference to be created.
404///
405/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfontuifonttype?language=objc)
406// NS_ENUM
407#[repr(transparent)]
408#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
409pub struct CTFontUIFontType(pub u32);
410impl CTFontUIFontType {
411    #[doc(alias = "kCTFontUIFontNone")]
412    pub const None: Self = Self(4294967295);
413    #[doc(alias = "kCTFontUIFontUser")]
414    pub const User: Self = Self(0);
415    #[doc(alias = "kCTFontUIFontUserFixedPitch")]
416    pub const UserFixedPitch: Self = Self(1);
417    #[doc(alias = "kCTFontUIFontSystem")]
418    pub const System: Self = Self(2);
419    #[doc(alias = "kCTFontUIFontEmphasizedSystem")]
420    pub const EmphasizedSystem: Self = Self(3);
421    #[doc(alias = "kCTFontUIFontSmallSystem")]
422    pub const SmallSystem: Self = Self(4);
423    #[doc(alias = "kCTFontUIFontSmallEmphasizedSystem")]
424    pub const SmallEmphasizedSystem: Self = Self(5);
425    #[doc(alias = "kCTFontUIFontMiniSystem")]
426    pub const MiniSystem: Self = Self(6);
427    #[doc(alias = "kCTFontUIFontMiniEmphasizedSystem")]
428    pub const MiniEmphasizedSystem: Self = Self(7);
429    #[doc(alias = "kCTFontUIFontViews")]
430    pub const Views: Self = Self(8);
431    #[doc(alias = "kCTFontUIFontApplication")]
432    pub const Application: Self = Self(9);
433    #[doc(alias = "kCTFontUIFontLabel")]
434    pub const Label: Self = Self(10);
435    #[doc(alias = "kCTFontUIFontMenuTitle")]
436    pub const MenuTitle: Self = Self(11);
437    #[doc(alias = "kCTFontUIFontMenuItem")]
438    pub const MenuItem: Self = Self(12);
439    #[doc(alias = "kCTFontUIFontMenuItemMark")]
440    pub const MenuItemMark: Self = Self(13);
441    #[doc(alias = "kCTFontUIFontMenuItemCmdKey")]
442    pub const MenuItemCmdKey: Self = Self(14);
443    #[doc(alias = "kCTFontUIFontWindowTitle")]
444    pub const WindowTitle: Self = Self(15);
445    #[doc(alias = "kCTFontUIFontPushButton")]
446    pub const PushButton: Self = Self(16);
447    #[doc(alias = "kCTFontUIFontUtilityWindowTitle")]
448    pub const UtilityWindowTitle: Self = Self(17);
449    #[doc(alias = "kCTFontUIFontAlertHeader")]
450    pub const AlertHeader: Self = Self(18);
451    #[doc(alias = "kCTFontUIFontSystemDetail")]
452    pub const SystemDetail: Self = Self(19);
453    #[doc(alias = "kCTFontUIFontEmphasizedSystemDetail")]
454    pub const EmphasizedSystemDetail: Self = Self(20);
455    #[doc(alias = "kCTFontUIFontToolbar")]
456    pub const Toolbar: Self = Self(21);
457    #[doc(alias = "kCTFontUIFontSmallToolbar")]
458    pub const SmallToolbar: Self = Self(22);
459    #[doc(alias = "kCTFontUIFontMessage")]
460    pub const Message: Self = Self(23);
461    #[doc(alias = "kCTFontUIFontPalette")]
462    pub const Palette: Self = Self(24);
463    #[doc(alias = "kCTFontUIFontToolTip")]
464    pub const ToolTip: Self = Self(25);
465    #[doc(alias = "kCTFontUIFontControlContent")]
466    pub const ControlContent: Self = Self(26);
467    #[deprecated = "Deprecated"]
468    pub const kCTFontNoFontType: Self = Self(CTFontUIFontType::None.0);
469    #[deprecated = "Deprecated"]
470    pub const kCTFontUserFontType: Self = Self(CTFontUIFontType::User.0);
471    #[deprecated = "Deprecated"]
472    pub const kCTFontUserFixedPitchFontType: Self = Self(CTFontUIFontType::UserFixedPitch.0);
473    #[deprecated = "Deprecated"]
474    pub const kCTFontSystemFontType: Self = Self(CTFontUIFontType::System.0);
475    #[deprecated = "Deprecated"]
476    pub const kCTFontEmphasizedSystemFontType: Self = Self(CTFontUIFontType::EmphasizedSystem.0);
477    #[deprecated = "Deprecated"]
478    pub const kCTFontSmallSystemFontType: Self = Self(CTFontUIFontType::SmallSystem.0);
479    #[deprecated = "Deprecated"]
480    pub const kCTFontSmallEmphasizedSystemFontType: Self =
481        Self(CTFontUIFontType::SmallEmphasizedSystem.0);
482    #[deprecated = "Deprecated"]
483    pub const kCTFontMiniSystemFontType: Self = Self(CTFontUIFontType::MiniSystem.0);
484    #[deprecated = "Deprecated"]
485    pub const kCTFontMiniEmphasizedSystemFontType: Self =
486        Self(CTFontUIFontType::MiniEmphasizedSystem.0);
487    #[deprecated = "Deprecated"]
488    pub const kCTFontViewsFontType: Self = Self(CTFontUIFontType::Views.0);
489    #[deprecated = "Deprecated"]
490    pub const kCTFontApplicationFontType: Self = Self(CTFontUIFontType::Application.0);
491    #[deprecated = "Deprecated"]
492    pub const kCTFontLabelFontType: Self = Self(CTFontUIFontType::Label.0);
493    #[deprecated = "Deprecated"]
494    pub const kCTFontMenuTitleFontType: Self = Self(CTFontUIFontType::MenuTitle.0);
495    #[deprecated = "Deprecated"]
496    pub const kCTFontMenuItemFontType: Self = Self(CTFontUIFontType::MenuItem.0);
497    #[deprecated = "Deprecated"]
498    pub const kCTFontMenuItemMarkFontType: Self = Self(CTFontUIFontType::MenuItemMark.0);
499    #[deprecated = "Deprecated"]
500    pub const kCTFontMenuItemCmdKeyFontType: Self = Self(CTFontUIFontType::MenuItemCmdKey.0);
501    #[deprecated = "Deprecated"]
502    pub const kCTFontWindowTitleFontType: Self = Self(CTFontUIFontType::WindowTitle.0);
503    #[deprecated = "Deprecated"]
504    pub const kCTFontPushButtonFontType: Self = Self(CTFontUIFontType::PushButton.0);
505    #[deprecated = "Deprecated"]
506    pub const kCTFontUtilityWindowTitleFontType: Self =
507        Self(CTFontUIFontType::UtilityWindowTitle.0);
508    #[deprecated = "Deprecated"]
509    pub const kCTFontAlertHeaderFontType: Self = Self(CTFontUIFontType::AlertHeader.0);
510    #[deprecated = "Deprecated"]
511    pub const kCTFontSystemDetailFontType: Self = Self(CTFontUIFontType::SystemDetail.0);
512    #[deprecated = "Deprecated"]
513    pub const kCTFontEmphasizedSystemDetailFontType: Self =
514        Self(CTFontUIFontType::EmphasizedSystemDetail.0);
515    #[deprecated = "Deprecated"]
516    pub const kCTFontToolbarFontType: Self = Self(CTFontUIFontType::Toolbar.0);
517    #[deprecated = "Deprecated"]
518    pub const kCTFontSmallToolbarFontType: Self = Self(CTFontUIFontType::SmallToolbar.0);
519    #[deprecated = "Deprecated"]
520    pub const kCTFontMessageFontType: Self = Self(CTFontUIFontType::Message.0);
521    #[deprecated = "Deprecated"]
522    pub const kCTFontPaletteFontType: Self = Self(CTFontUIFontType::Palette.0);
523    #[deprecated = "Deprecated"]
524    pub const kCTFontToolTipFontType: Self = Self(CTFontUIFontType::ToolTip.0);
525    #[deprecated = "Deprecated"]
526    pub const kCTFontControlContentFontType: Self = Self(CTFontUIFontType::ControlContent.0);
527}
528
529#[cfg(feature = "objc2")]
530unsafe impl Encode for CTFontUIFontType {
531    const ENCODING: Encoding = u32::ENCODING;
532}
533
534#[cfg(feature = "objc2")]
535unsafe impl RefEncode for CTFontUIFontType {
536    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
537}
538
539impl CTFont {
540    /// Returns the special UI font for the given language and UI type.
541    ///
542    ///
543    /// Parameter `uiType`: A uiType constant specifying the intended UI use for the requested font reference.
544    ///
545    ///
546    /// Parameter `size`: The point size for the font reference. If 0.0 is specified, the default size for the requested uiType is used.
547    ///
548    ///
549    /// Parameter `language`: Language identifier to select a font for a particular localization. If unspecified, the current system language is used. The format of the language identifier should conform to UTS #35.
550    ///
551    ///
552    /// Returns: This function returns the correct font for various UI uses. The only required parameter is the uiType selector, unspecified optional parameters will use default values.
553    #[doc(alias = "CTFontCreateUIFontForLanguage")]
554    #[inline]
555    pub unsafe fn new_ui_font_for_language(
556        ui_type: CTFontUIFontType,
557        size: CGFloat,
558        language: Option<&CFString>,
559    ) -> Option<CFRetained<CTFont>> {
560        extern "C-unwind" {
561            fn CTFontCreateUIFontForLanguage(
562                ui_type: CTFontUIFontType,
563                size: CGFloat,
564                language: Option<&CFString>,
565            ) -> Option<NonNull<CTFont>>;
566        }
567        let ret = unsafe { CTFontCreateUIFontForLanguage(ui_type, size, language) };
568        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
569    }
570
571    /// Returns a new font with additional attributes based on the original font.
572    ///
573    ///
574    /// This function provides a mechanism to quickly change attributes on a given font reference in response to user actions. For instance, the size can be changed in response to a user manipulating a size slider.
575    ///
576    ///
577    /// Parameter `font`: Original font reference to base new font on.
578    ///
579    ///
580    /// Parameter `size`: The point size for the font reference. If 0.0 is specified, the original font's size will be preserved.
581    ///
582    ///
583    /// Parameter `matrix`: The transformation matrix for the font. If unspecified, the original font matrix will be preserved. Optional.
584    ///
585    ///
586    /// Parameter `attributes`: A font descriptor containing additional attributes that the new font should contain.
587    ///
588    ///
589    /// Returns: Returns a new font reference converted from the original with the specified attributes.
590    #[doc(alias = "CTFontCreateCopyWithAttributes")]
591    #[cfg(feature = "CTFontDescriptor")]
592    #[inline]
593    pub unsafe fn copy_with_attributes(
594        self: &CTFont,
595        size: CGFloat,
596        matrix: *const CGAffineTransform,
597        attributes: Option<&CTFontDescriptor>,
598    ) -> CFRetained<CTFont> {
599        extern "C-unwind" {
600            fn CTFontCreateCopyWithAttributes(
601                font: &CTFont,
602                size: CGFloat,
603                matrix: *const CGAffineTransform,
604                attributes: Option<&CTFontDescriptor>,
605            ) -> Option<NonNull<CTFont>>;
606        }
607        let ret = unsafe { CTFontCreateCopyWithAttributes(self, size, matrix, attributes) };
608        let ret =
609            ret.expect("function was marked as returning non-null, but actually returned NULL");
610        unsafe { CFRetained::from_raw(ret) }
611    }
612
613    /// Returns a new font based on the original font with the specified symbolic traits.
614    ///
615    ///
616    /// Parameter `font`: Original font reference on which to base the new font.
617    ///
618    ///
619    /// Parameter `size`: The point size for the font reference. If 0.0 is specified, the original font's size will be preserved.
620    ///
621    ///
622    /// Parameter `matrix`: The transformation matrix for the font. If unspecified, the original font matrix will be preserved. Optional.
623    ///
624    ///
625    /// 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.
626    ///
627    ///
628    /// Parameter `symTraitMask`: The mask bits of the symbolic traits. This bitfield is used to indicate the traits that should be changed.
629    ///
630    ///
631    /// Returns: Returns a new font reference in the same family with the given symbolic traits, or NULL if none found in the system.
632    #[doc(alias = "CTFontCreateCopyWithSymbolicTraits")]
633    #[cfg(feature = "CTFontTraits")]
634    #[inline]
635    pub unsafe fn copy_with_symbolic_traits(
636        self: &CTFont,
637        size: CGFloat,
638        matrix: *const CGAffineTransform,
639        sym_trait_value: CTFontSymbolicTraits,
640        sym_trait_mask: CTFontSymbolicTraits,
641    ) -> Option<CFRetained<CTFont>> {
642        extern "C-unwind" {
643            fn CTFontCreateCopyWithSymbolicTraits(
644                font: &CTFont,
645                size: CGFloat,
646                matrix: *const CGAffineTransform,
647                sym_trait_value: CTFontSymbolicTraits,
648                sym_trait_mask: CTFontSymbolicTraits,
649            ) -> Option<NonNull<CTFont>>;
650        }
651        let ret = unsafe {
652            CTFontCreateCopyWithSymbolicTraits(self, size, matrix, sym_trait_value, sym_trait_mask)
653        };
654        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
655    }
656
657    /// Returns a new font in the specified family based on the traits of the original font.
658    ///
659    ///
660    /// Parameter `font`: Original font reference to base new font on.
661    ///
662    ///
663    /// Parameter `size`: The point size for the font reference. If 0.0 is specified, the original font's size will be preserved.
664    ///
665    ///
666    /// Parameter `matrix`: The transformation matrix for the font. If unspecified, the original font matrix will be preserved. Optional.
667    ///
668    ///
669    /// Parameter `family`: The name of the desired family.
670    ///
671    ///
672    /// Returns: Returns a new font reference with the original traits in the given family. NULL if non found in the system.
673    #[doc(alias = "CTFontCreateCopyWithFamily")]
674    #[inline]
675    pub unsafe fn copy_with_family(
676        self: &CTFont,
677        size: CGFloat,
678        matrix: *const CGAffineTransform,
679        family: &CFString,
680    ) -> Option<CFRetained<CTFont>> {
681        extern "C-unwind" {
682            fn CTFontCreateCopyWithFamily(
683                font: &CTFont,
684                size: CGFloat,
685                matrix: *const CGAffineTransform,
686                family: &CFString,
687            ) -> Option<NonNull<CTFont>>;
688        }
689        let ret = unsafe { CTFontCreateCopyWithFamily(self, size, matrix, family) };
690        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
691    }
692
693    /// Returns a new font reference that can best map the given string range based on the current font.
694    ///
695    ///
696    /// This function is to be used when the current font does not cover the given range of the string. The current font itself will not be returned, but preference is given to fonts in its cascade list.
697    ///
698    ///
699    /// Parameter `currentFont`: The current font that contains a valid cascade list.
700    ///
701    ///
702    /// Parameter `string`: A unicode string containing characters that cannot be encoded by the current font.
703    ///
704    ///
705    /// Parameter `range`: A CFRange specifying the range of the string that needs to be mapped.
706    ///
707    ///
708    /// Returns: This function returns the best substitute font that can encode the specified string range.
709    ///
710    ///
711    /// See also: CTFontCopyCharacterSet
712    ///
713    /// See also: CTFontGetGlyphsForCharacters
714    ///
715    /// See also: kCTFontCascadeListAttribute
716    #[doc(alias = "CTFontCreateForString")]
717    #[inline]
718    pub unsafe fn for_string(
719        self: &CTFont,
720        string: &CFString,
721        range: CFRange,
722    ) -> CFRetained<CTFont> {
723        extern "C-unwind" {
724            fn CTFontCreateForString(
725                current_font: &CTFont,
726                string: &CFString,
727                range: CFRange,
728            ) -> Option<NonNull<CTFont>>;
729        }
730        let ret = unsafe { CTFontCreateForString(self, string, range) };
731        let ret =
732            ret.expect("function was marked as returning non-null, but actually returned NULL");
733        unsafe { CFRetained::from_raw(ret) }
734    }
735
736    /// Returns a new font reference that can best map the given string range based on the current font and language specified.
737    ///
738    ///
739    /// The current font itself can be returned if it covers the string provided.
740    ///
741    ///
742    /// Parameter `currentFont`: The current font that contains a valid cascade list.
743    ///
744    ///
745    /// Parameter `string`: A unicode string containing characters that cannot be encoded by the current font.
746    ///
747    ///
748    /// Parameter `range`: A CFRange specifying the range of the string that needs to be mapped.
749    ///
750    ///
751    /// Parameter `language`: Language identifier to select a font for a particular localization. If unspecified, the current system language is used. The format of the language identifier should conform to UTS #35.
752    ///
753    ///
754    /// Returns: This function returns the best substitute font that can encode the specified string range.
755    ///
756    ///
757    /// See also: CTFontCopyCharacterSet
758    ///
759    /// See also: CTFontGetGlyphsForCharacters
760    ///
761    /// See also: kCTFontCascadeListAttribute
762    #[doc(alias = "CTFontCreateForStringWithLanguage")]
763    #[inline]
764    pub unsafe fn for_string_with_language(
765        self: &CTFont,
766        string: &CFString,
767        range: CFRange,
768        language: Option<&CFString>,
769    ) -> CFRetained<CTFont> {
770        extern "C-unwind" {
771            fn CTFontCreateForStringWithLanguage(
772                current_font: &CTFont,
773                string: &CFString,
774                range: CFRange,
775                language: Option<&CFString>,
776            ) -> Option<NonNull<CTFont>>;
777        }
778        let ret = unsafe { CTFontCreateForStringWithLanguage(self, string, range, language) };
779        let ret =
780            ret.expect("function was marked as returning non-null, but actually returned NULL");
781        unsafe { CFRetained::from_raw(ret) }
782    }
783
784    /// Returns the normalized font descriptors for the given font reference.
785    ///
786    ///
787    /// Parameter `font`: The font reference.
788    ///
789    ///
790    /// Returns: This function returns a normalized font descriptor for a font. The font descriptor contains enough information to recreate this font at a later time.
791    #[doc(alias = "CTFontCopyFontDescriptor")]
792    #[cfg(feature = "CTFontDescriptor")]
793    #[inline]
794    pub unsafe fn font_descriptor(self: &CTFont) -> CFRetained<CTFontDescriptor> {
795        extern "C-unwind" {
796            fn CTFontCopyFontDescriptor(font: &CTFont) -> Option<NonNull<CTFontDescriptor>>;
797        }
798        let ret = unsafe { CTFontCopyFontDescriptor(self) };
799        let ret =
800            ret.expect("function was marked as returning non-null, but actually returned NULL");
801        unsafe { CFRetained::from_raw(ret) }
802    }
803
804    /// Returns the value associated with an arbitrary attribute.
805    ///
806    ///
807    /// Parameter `font`: The font reference.
808    ///
809    ///
810    /// Parameter `attribute`: The requested attribute.
811    ///
812    ///
813    /// Returns: This function returns a retained reference to an arbitrary attribute. If the requested attribute is not present, NULL is returned. Refer to the attribute definitions for documentation as to how each attribute is packaged as a CFType.
814    #[doc(alias = "CTFontCopyAttribute")]
815    #[inline]
816    pub unsafe fn attribute(self: &CTFont, attribute: &CFString) -> Option<CFRetained<CFType>> {
817        extern "C-unwind" {
818            fn CTFontCopyAttribute(font: &CTFont, attribute: &CFString) -> Option<NonNull<CFType>>;
819        }
820        let ret = unsafe { CTFontCopyAttribute(self, attribute) };
821        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
822    }
823
824    /// Returns the point size of the font reference.
825    ///
826    ///
827    /// Parameter `font`: The font reference.
828    ///
829    ///
830    /// Returns: This function returns the point size of the given font reference. This is the point size provided when the font was created.
831    #[doc(alias = "CTFontGetSize")]
832    #[inline]
833    pub unsafe fn size(self: &CTFont) -> CGFloat {
834        extern "C-unwind" {
835            fn CTFontGetSize(font: &CTFont) -> CGFloat;
836        }
837        unsafe { CTFontGetSize(self) }
838    }
839
840    /// Returns the transformation matrix of the font.
841    ///
842    ///
843    /// Parameter `font`: The font reference.
844    ///
845    ///
846    /// Returns: This function returns the transformation matrix for this given font reference. This is the matrix that was provided when the font was created.
847    #[doc(alias = "CTFontGetMatrix")]
848    #[inline]
849    pub unsafe fn matrix(self: &CTFont) -> CGAffineTransform {
850        extern "C-unwind" {
851            fn CTFontGetMatrix(font: &CTFont) -> CGAffineTransform;
852        }
853        unsafe { CTFontGetMatrix(self) }
854    }
855
856    /// Returns the symbolic font traits.
857    ///
858    ///
859    /// Parameter `font`: The font reference.
860    ///
861    ///
862    /// Returns: This function returns the symbolic traits of the font. This is equivalent to the kCTFontSymbolicTrait of traits dictionary. See CTFontTraits.h for a definition of the font traits.
863    #[doc(alias = "CTFontGetSymbolicTraits")]
864    #[cfg(feature = "CTFontTraits")]
865    #[inline]
866    pub unsafe fn symbolic_traits(self: &CTFont) -> CTFontSymbolicTraits {
867        extern "C-unwind" {
868            fn CTFontGetSymbolicTraits(font: &CTFont) -> CTFontSymbolicTraits;
869        }
870        unsafe { CTFontGetSymbolicTraits(self) }
871    }
872
873    /// Returns the font traits dictionary.
874    ///
875    ///
876    /// Parameter `font`: The font reference.
877    ///
878    ///
879    /// Returns: This function returns a retained reference to the font traits dictionary. Individual traits can be accessed with the trait key constants. See CTFontTraits.h for a definition of the font traits.
880    #[doc(alias = "CTFontCopyTraits")]
881    #[inline]
882    pub unsafe fn traits(self: &CTFont) -> CFRetained<CFDictionary> {
883        extern "C-unwind" {
884            fn CTFontCopyTraits(font: &CTFont) -> Option<NonNull<CFDictionary>>;
885        }
886        let ret = unsafe { CTFontCopyTraits(self) };
887        let ret =
888            ret.expect("function was marked as returning non-null, but actually returned NULL");
889        unsafe { CFRetained::from_raw(ret) }
890    }
891
892    /// Return an ordered list of CTFontDescriptorRef's for font fallback derived from the system default fallback according to the given language preferences, making a reasonable attempt to match the given font's style, weight, and width.
893    ///
894    ///
895    /// Parameter `font`: The font reference.
896    ///
897    ///
898    /// Parameter `languagePrefList`: An array of language identifiers as CFString values, in decreasing order of preference.
899    ///
900    ///
901    /// Returns: The ordered list of fallback fonts - ordered array of CTFontDescriptors.
902    #[doc(alias = "CTFontCopyDefaultCascadeListForLanguages")]
903    #[inline]
904    pub unsafe fn default_cascade_list_for_languages(
905        self: &CTFont,
906        language_pref_list: Option<&CFArray>,
907    ) -> Option<CFRetained<CFArray>> {
908        extern "C-unwind" {
909            fn CTFontCopyDefaultCascadeListForLanguages(
910                font: &CTFont,
911                language_pref_list: Option<&CFArray>,
912            ) -> Option<NonNull<CFArray>>;
913        }
914        let ret = unsafe { CTFontCopyDefaultCascadeListForLanguages(self, language_pref_list) };
915        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
916    }
917
918    /// Returns the PostScript name.
919    ///
920    ///
921    /// Parameter `font`: The font reference.
922    ///
923    ///
924    /// Returns: This function returns a retained reference to the PostScript name of the font.
925    #[doc(alias = "CTFontCopyPostScriptName")]
926    #[inline]
927    pub unsafe fn post_script_name(self: &CTFont) -> CFRetained<CFString> {
928        extern "C-unwind" {
929            fn CTFontCopyPostScriptName(font: &CTFont) -> Option<NonNull<CFString>>;
930        }
931        let ret = unsafe { CTFontCopyPostScriptName(self) };
932        let ret =
933            ret.expect("function was marked as returning non-null, but actually returned NULL");
934        unsafe { CFRetained::from_raw(ret) }
935    }
936
937    /// Returns the family name.
938    ///
939    ///
940    /// Parameter `font`: The font reference.
941    ///
942    ///
943    /// Returns: This function returns a retained reference to the family name of the font.
944    #[doc(alias = "CTFontCopyFamilyName")]
945    #[inline]
946    pub unsafe fn family_name(self: &CTFont) -> CFRetained<CFString> {
947        extern "C-unwind" {
948            fn CTFontCopyFamilyName(font: &CTFont) -> Option<NonNull<CFString>>;
949        }
950        let ret = unsafe { CTFontCopyFamilyName(self) };
951        let ret =
952            ret.expect("function was marked as returning non-null, but actually returned NULL");
953        unsafe { CFRetained::from_raw(ret) }
954    }
955
956    /// Returns the display name.
957    ///
958    ///
959    /// Parameter `font`: The font reference.
960    ///
961    ///
962    /// Returns: This function returns a retained reference to the full name of the font.
963    #[doc(alias = "CTFontCopyFullName")]
964    #[inline]
965    pub unsafe fn full_name(self: &CTFont) -> CFRetained<CFString> {
966        extern "C-unwind" {
967            fn CTFontCopyFullName(font: &CTFont) -> Option<NonNull<CFString>>;
968        }
969        let ret = unsafe { CTFontCopyFullName(self) };
970        let ret =
971            ret.expect("function was marked as returning non-null, but actually returned NULL");
972        unsafe { CFRetained::from_raw(ret) }
973    }
974
975    /// Returns the display name.
976    ///
977    ///
978    /// Parameter `font`: The font reference.
979    ///
980    ///
981    /// Returns: This function returns a retained reference to the localized display name of the font.
982    #[doc(alias = "CTFontCopyDisplayName")]
983    #[inline]
984    pub unsafe fn display_name(self: &CTFont) -> CFRetained<CFString> {
985        extern "C-unwind" {
986            fn CTFontCopyDisplayName(font: &CTFont) -> Option<NonNull<CFString>>;
987        }
988        let ret = unsafe { CTFontCopyDisplayName(self) };
989        let ret =
990            ret.expect("function was marked as returning non-null, but actually returned NULL");
991        unsafe { CFRetained::from_raw(ret) }
992    }
993
994    /// Returns a reference to the requested name.
995    ///
996    ///
997    /// Parameter `font`: The font reference.
998    ///
999    ///
1000    /// Parameter `nameKey`: The name specifier. See name specifier constants.
1001    ///
1002    ///
1003    /// Returns: This function creates the requested name for the font, or NULL if the font does not have an entry for the requested name. The Unicode version of the name will be preferred, otherwise the first available will be used.
1004    #[doc(alias = "CTFontCopyName")]
1005    #[inline]
1006    pub unsafe fn name(self: &CTFont, name_key: &CFString) -> Option<CFRetained<CFString>> {
1007        extern "C-unwind" {
1008            fn CTFontCopyName(font: &CTFont, name_key: &CFString) -> Option<NonNull<CFString>>;
1009        }
1010        let ret = unsafe { CTFontCopyName(self, name_key) };
1011        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1012    }
1013
1014    /// Returns a reference to a localized font name.
1015    ///
1016    ///
1017    /// Parameter `font`: The font reference.
1018    ///
1019    ///
1020    /// Parameter `nameKey`: The name specifier. See name specifier constants.
1021    ///
1022    ///
1023    /// Parameter `actualLanguage`: Pointer to a CFStringRef to receive the language identifier of the returned name string. The format of the language identifier will conform to UTS #35.
1024    /// If CoreText can supply its own localized string where the font cannot, this value will be NULL.
1025    ///
1026    ///
1027    /// Returns: This function returns a specific localized name from the font reference. The name is localized based on the user's global language precedence. If the font does not have an entry for the requested name, NULL will be returned. The matched language will be returned in the caller's buffer.
1028    #[doc(alias = "CTFontCopyLocalizedName")]
1029    #[inline]
1030    pub unsafe fn localized_name(
1031        self: &CTFont,
1032        name_key: &CFString,
1033        actual_language: *mut *const CFString,
1034    ) -> Option<CFRetained<CFString>> {
1035        extern "C-unwind" {
1036            fn CTFontCopyLocalizedName(
1037                font: &CTFont,
1038                name_key: &CFString,
1039                actual_language: *mut *const CFString,
1040            ) -> Option<NonNull<CFString>>;
1041        }
1042        let ret = unsafe { CTFontCopyLocalizedName(self, name_key, actual_language) };
1043        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1044    }
1045
1046    /// Returns the Unicode character set of the font.
1047    ///
1048    ///
1049    /// Parameter `font`: The font reference.
1050    ///
1051    ///
1052    /// Returns: This function returns a retained reference to the font's character set. This character set covers the nominal referenced by the font's Unicode cmap table (or equivalent).
1053    #[doc(alias = "CTFontCopyCharacterSet")]
1054    #[inline]
1055    pub unsafe fn character_set(self: &CTFont) -> CFRetained<CFCharacterSet> {
1056        extern "C-unwind" {
1057            fn CTFontCopyCharacterSet(font: &CTFont) -> Option<NonNull<CFCharacterSet>>;
1058        }
1059        let ret = unsafe { CTFontCopyCharacterSet(self) };
1060        let ret =
1061            ret.expect("function was marked as returning non-null, but actually returned NULL");
1062        unsafe { CFRetained::from_raw(ret) }
1063    }
1064
1065    /// Returns the best string encoding for legacy format support.
1066    ///
1067    ///
1068    /// Parameter `font`: The font reference.
1069    ///
1070    ///
1071    /// Returns: This function returns the best string encoding for the font.
1072    #[doc(alias = "CTFontGetStringEncoding")]
1073    #[inline]
1074    pub unsafe fn string_encoding(self: &CTFont) -> CFStringEncoding {
1075        extern "C-unwind" {
1076            fn CTFontGetStringEncoding(font: &CTFont) -> CFStringEncoding;
1077        }
1078        unsafe { CTFontGetStringEncoding(self) }
1079    }
1080
1081    /// Returns an array of languages supported by the font.
1082    ///
1083    ///
1084    /// Parameter `font`: The font reference.
1085    ///
1086    ///
1087    /// Returns: This function returns a retained reference to an array of languages supported by the font. The array contains language identifier strings as CFStringRefs. The format of the language identifier will conform to UTS #35.
1088    #[doc(alias = "CTFontCopySupportedLanguages")]
1089    #[inline]
1090    pub unsafe fn supported_languages(self: &CTFont) -> CFRetained<CFArray> {
1091        extern "C-unwind" {
1092            fn CTFontCopySupportedLanguages(font: &CTFont) -> Option<NonNull<CFArray>>;
1093        }
1094        let ret = unsafe { CTFontCopySupportedLanguages(self) };
1095        let ret =
1096            ret.expect("function was marked as returning non-null, but actually returned NULL");
1097        unsafe { CFRetained::from_raw(ret) }
1098    }
1099
1100    /// Performs basic character-to-glyph mapping.
1101    ///
1102    ///
1103    /// This function only provides the nominal mapping as specified by the font's Unicode cmap (or equivalent); such mapping does not constitute proper Unicode layout: it is the caller's responsibility to handle the Unicode properties of the characters.
1104    ///
1105    ///
1106    /// Parameter `font`: The font reference.
1107    ///
1108    ///
1109    /// Parameter `characters`: An array of characters (UTF-16 code units). Non-BMP characters must be encoded as surrogate pairs.
1110    ///
1111    ///
1112    /// Parameter `glyphs`: A pointer to a buffer to receive the glyphs. Glyphs for non-BMP characters are sparse: the first glyph corresponds to the full character and the second glyph will be 0.
1113    ///
1114    ///
1115    /// Parameter `count`: The capacity of both the characters and glyphs arrays.
1116    ///
1117    ///
1118    /// Returns: The return value indicates whether all provided characters were successfully mapped. A return value of true indicates that the font mapped all characters. A return value of false indicates that some or all of the characters were not mapped; glyphs for unmapped characters will be 0 (with the exception of those corresponding non-BMP characters as described above).
1119    ///
1120    ///
1121    /// See also: CTFontCopyCharacterSet
1122    #[doc(alias = "CTFontGetGlyphsForCharacters")]
1123    #[cfg(feature = "objc2-core-graphics")]
1124    #[inline]
1125    pub unsafe fn glyphs_for_characters(
1126        self: &CTFont,
1127        characters: NonNull<UniChar>,
1128        glyphs: NonNull<CGGlyph>,
1129        count: CFIndex,
1130    ) -> bool {
1131        extern "C-unwind" {
1132            fn CTFontGetGlyphsForCharacters(
1133                font: &CTFont,
1134                characters: NonNull<UniChar>,
1135                glyphs: NonNull<CGGlyph>,
1136                count: CFIndex,
1137            ) -> bool;
1138        }
1139        unsafe { CTFontGetGlyphsForCharacters(self, characters, glyphs, count) }
1140    }
1141
1142    /// Returns the scaled font ascent metric.
1143    ///
1144    ///
1145    /// Parameter `font`: The font reference.
1146    ///
1147    ///
1148    /// Returns: This function returns the font ascent metric scaled based on the point size and matrix of the font reference.
1149    #[doc(alias = "CTFontGetAscent")]
1150    #[inline]
1151    pub unsafe fn ascent(self: &CTFont) -> CGFloat {
1152        extern "C-unwind" {
1153            fn CTFontGetAscent(font: &CTFont) -> CGFloat;
1154        }
1155        unsafe { CTFontGetAscent(self) }
1156    }
1157
1158    /// Returns the scaled font descent metric.
1159    ///
1160    ///
1161    /// Parameter `font`: The font reference.
1162    ///
1163    ///
1164    /// Returns: This function returns the font descent metric scaled based on the point size and matrix of the font reference.
1165    #[doc(alias = "CTFontGetDescent")]
1166    #[inline]
1167    pub unsafe fn descent(self: &CTFont) -> CGFloat {
1168        extern "C-unwind" {
1169            fn CTFontGetDescent(font: &CTFont) -> CGFloat;
1170        }
1171        unsafe { CTFontGetDescent(self) }
1172    }
1173
1174    /// Returns the scaled font leading metric.
1175    ///
1176    ///
1177    /// Parameter `font`: The font reference.
1178    ///
1179    ///
1180    /// Returns: This function returns the font leading metric scaled based on the point size and matrix of the font reference.
1181    #[doc(alias = "CTFontGetLeading")]
1182    #[inline]
1183    pub unsafe fn leading(self: &CTFont) -> CGFloat {
1184        extern "C-unwind" {
1185            fn CTFontGetLeading(font: &CTFont) -> CGFloat;
1186        }
1187        unsafe { CTFontGetLeading(self) }
1188    }
1189
1190    /// Returns the units per em metric.
1191    ///
1192    ///
1193    /// Parameter `font`: The font reference.
1194    ///
1195    ///
1196    /// Returns: This function returns the units per em of the font.
1197    #[doc(alias = "CTFontGetUnitsPerEm")]
1198    #[inline]
1199    pub unsafe fn units_per_em(self: &CTFont) -> c_uint {
1200        extern "C-unwind" {
1201            fn CTFontGetUnitsPerEm(font: &CTFont) -> c_uint;
1202        }
1203        unsafe { CTFontGetUnitsPerEm(self) }
1204    }
1205
1206    /// Returns the number of glyphs.
1207    ///
1208    ///
1209    /// Parameter `font`: The font reference.
1210    ///
1211    ///
1212    /// Returns: This function returns the number of glyphs in the font.
1213    #[doc(alias = "CTFontGetGlyphCount")]
1214    #[inline]
1215    pub unsafe fn glyph_count(self: &CTFont) -> CFIndex {
1216        extern "C-unwind" {
1217            fn CTFontGetGlyphCount(font: &CTFont) -> CFIndex;
1218        }
1219        unsafe { CTFontGetGlyphCount(self) }
1220    }
1221
1222    /// Returns the scaled bounding box.
1223    ///
1224    ///
1225    /// Parameter `font`: The font reference.
1226    ///
1227    ///
1228    /// Returns: This will return the design bounding box of the font, which is the rectangle defined by xMin, yMin, xMax, and yMax values for the font.
1229    #[doc(alias = "CTFontGetBoundingBox")]
1230    #[inline]
1231    pub unsafe fn bounding_box(self: &CTFont) -> CGRect {
1232        extern "C-unwind" {
1233            fn CTFontGetBoundingBox(font: &CTFont) -> CGRect;
1234        }
1235        unsafe { CTFontGetBoundingBox(self) }
1236    }
1237
1238    /// Returns the scaled underline position.
1239    ///
1240    ///
1241    /// Parameter `font`: The font reference.
1242    ///
1243    ///
1244    /// Returns: This function returns the font underline position metric scaled based on the point size and matrix of the font reference.
1245    #[doc(alias = "CTFontGetUnderlinePosition")]
1246    #[inline]
1247    pub unsafe fn underline_position(self: &CTFont) -> CGFloat {
1248        extern "C-unwind" {
1249            fn CTFontGetUnderlinePosition(font: &CTFont) -> CGFloat;
1250        }
1251        unsafe { CTFontGetUnderlinePosition(self) }
1252    }
1253
1254    /// Returns the scaled underline thickness metric.
1255    ///
1256    ///
1257    /// Parameter `font`: The font reference.
1258    ///
1259    ///
1260    /// Returns: This function returns the font underline thickness metric scaled based on the point size and matrix of the font reference.
1261    #[doc(alias = "CTFontGetUnderlineThickness")]
1262    #[inline]
1263    pub unsafe fn underline_thickness(self: &CTFont) -> CGFloat {
1264        extern "C-unwind" {
1265            fn CTFontGetUnderlineThickness(font: &CTFont) -> CGFloat;
1266        }
1267        unsafe { CTFontGetUnderlineThickness(self) }
1268    }
1269
1270    /// Returns the slant angle of the font.
1271    ///
1272    ///
1273    /// Parameter `font`: The font reference.
1274    ///
1275    ///
1276    /// Returns: This function returns the transformed slant angle of the font. This is equivalent to the italic or caret angle with any skew from the transformation matrix applied.
1277    #[doc(alias = "CTFontGetSlantAngle")]
1278    #[inline]
1279    pub unsafe fn slant_angle(self: &CTFont) -> CGFloat {
1280        extern "C-unwind" {
1281            fn CTFontGetSlantAngle(font: &CTFont) -> CGFloat;
1282        }
1283        unsafe { CTFontGetSlantAngle(self) }
1284    }
1285
1286    /// Returns the cap height metric.
1287    ///
1288    ///
1289    /// Parameter `font`: The font reference.
1290    ///
1291    ///
1292    /// Returns: This function returns the font cap height metric scaled based on the point size and matrix of the font reference.
1293    #[doc(alias = "CTFontGetCapHeight")]
1294    #[inline]
1295    pub unsafe fn cap_height(self: &CTFont) -> CGFloat {
1296        extern "C-unwind" {
1297            fn CTFontGetCapHeight(font: &CTFont) -> CGFloat;
1298        }
1299        unsafe { CTFontGetCapHeight(self) }
1300    }
1301
1302    /// Returns the X height metric.
1303    ///
1304    ///
1305    /// Parameter `font`: The font reference.
1306    ///
1307    ///
1308    /// Returns: This function returns the font X height metric scaled based on the point size and matrix of the font reference.
1309    #[doc(alias = "CTFontGetXHeight")]
1310    #[inline]
1311    pub unsafe fn x_height(self: &CTFont) -> CGFloat {
1312        extern "C-unwind" {
1313            fn CTFontGetXHeight(font: &CTFont) -> CGFloat;
1314        }
1315        unsafe { CTFontGetXHeight(self) }
1316    }
1317
1318    /// Returns the CGGlyph for the specified glyph name.
1319    ///
1320    ///
1321    /// Parameter `font`: The font reference.
1322    ///
1323    ///
1324    /// Parameter `glyphName`: The glyph name as a CFString.
1325    ///
1326    ///
1327    /// Returns: The glyph with the specified name or 0 if the name is not recognized; this glyph can be used with other Core Text glyph data accessors or with Quartz.
1328    #[doc(alias = "CTFontGetGlyphWithName")]
1329    #[cfg(feature = "objc2-core-graphics")]
1330    #[inline]
1331    pub unsafe fn glyph_with_name(self: &CTFont, glyph_name: &CFString) -> CGGlyph {
1332        extern "C-unwind" {
1333            fn CTFontGetGlyphWithName(font: &CTFont, glyph_name: &CFString) -> CGGlyph;
1334        }
1335        unsafe { CTFontGetGlyphWithName(self, glyph_name) }
1336    }
1337
1338    /// Returns the name for the specified glyph.
1339    ///
1340    ///
1341    /// Parameter `font`: The font reference.
1342    ///
1343    ///
1344    /// Parameter `glyph`: The glyph.
1345    ///
1346    ///
1347    /// Returns: The glyph name as a CFString or NULL if the glyph is invalid.
1348    ///
1349    ///
1350    /// See also: CTFontGetGlyphWithName
1351    #[doc(alias = "CTFontCopyNameForGlyph")]
1352    #[cfg(feature = "objc2-core-graphics")]
1353    #[inline]
1354    pub unsafe fn name_for_glyph(self: &CTFont, glyph: CGGlyph) -> Option<CFRetained<CFString>> {
1355        extern "C-unwind" {
1356            fn CTFontCopyNameForGlyph(font: &CTFont, glyph: CGGlyph) -> Option<NonNull<CFString>>;
1357        }
1358        let ret = unsafe { CTFontCopyNameForGlyph(self, glyph) };
1359        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1360    }
1361
1362    /// Calculates the bounding rects for an array of glyphs and returns the overall bounding rect for the run.
1363    ///
1364    ///
1365    /// Parameter `font`: The font reference.
1366    ///
1367    ///
1368    /// Parameter `orientation`: The intended drawing orientation of the glyphs. Used to determined which glyph metrics to return.
1369    ///
1370    ///
1371    /// Parameter `glyphs`: An array of count number of glyphs.
1372    ///
1373    ///
1374    /// Parameter `boundingRects`: An array of count number of CGRects to receive the computed glyph rects. Can be NULL, in which case only the overall bounding rect is calculated.
1375    ///
1376    ///
1377    /// Parameter `count`: The capacity of the glyphs and boundingRects buffers.
1378    ///
1379    ///
1380    /// Returns: This function returns the overall bounding rectangle for an array or run of glyphs. The bounding rects of the individual glyphs are returned through the boundingRects parameter. These are the design metrics from the font transformed in font space.
1381    #[doc(alias = "CTFontGetBoundingRectsForGlyphs")]
1382    #[cfg(all(feature = "CTFontDescriptor", feature = "objc2-core-graphics"))]
1383    #[inline]
1384    pub unsafe fn bounding_rects_for_glyphs(
1385        self: &CTFont,
1386        orientation: CTFontOrientation,
1387        glyphs: NonNull<CGGlyph>,
1388        bounding_rects: *mut CGRect,
1389        count: CFIndex,
1390    ) -> CGRect {
1391        extern "C-unwind" {
1392            fn CTFontGetBoundingRectsForGlyphs(
1393                font: &CTFont,
1394                orientation: CTFontOrientation,
1395                glyphs: NonNull<CGGlyph>,
1396                bounding_rects: *mut CGRect,
1397                count: CFIndex,
1398            ) -> CGRect;
1399        }
1400        unsafe { CTFontGetBoundingRectsForGlyphs(self, orientation, glyphs, bounding_rects, count) }
1401    }
1402
1403    /// Calculates the optical bounding rects for an array of glyphs and returns the overall optical bounding rect for the run.
1404    ///
1405    ///
1406    /// Fonts may specify the optical edges of glyphs that can be used to make the edges of lines of text line up in a more visually pleasing way. This function returns bounding rects corresponding to this information if present in a font, otherwise it returns typographic bounding rects (composed of the font's ascent and descent and a glyph's advance width).
1407    ///
1408    ///
1409    /// Parameter `font`: The font reference.
1410    ///
1411    ///
1412    /// Parameter `glyphs`: An array of count number of glyphs.
1413    ///
1414    ///
1415    /// Parameter `boundingRects`: An array of count number of CGRects to receive the computed glyph rects. Can be NULL, in which case only the overall bounding rect is calculated.
1416    ///
1417    ///
1418    /// Parameter `count`: The capacity of the glyphs and boundingRects buffers.
1419    ///
1420    ///
1421    /// Parameter `options`: Reserved, set to zero.
1422    ///
1423    ///
1424    /// Returns: This function returns the overall bounding rectangle for an array or run of glyphs. The bounding rects of the individual glyphs are returned through the boundingRects parameter. These are the design metrics from the font transformed in font space.
1425    #[doc(alias = "CTFontGetOpticalBoundsForGlyphs")]
1426    #[cfg(feature = "objc2-core-graphics")]
1427    #[inline]
1428    pub unsafe fn optical_bounds_for_glyphs(
1429        self: &CTFont,
1430        glyphs: NonNull<CGGlyph>,
1431        bounding_rects: *mut CGRect,
1432        count: CFIndex,
1433        options: CFOptionFlags,
1434    ) -> CGRect {
1435        extern "C-unwind" {
1436            fn CTFontGetOpticalBoundsForGlyphs(
1437                font: &CTFont,
1438                glyphs: NonNull<CGGlyph>,
1439                bounding_rects: *mut CGRect,
1440                count: CFIndex,
1441                options: CFOptionFlags,
1442            ) -> CGRect;
1443        }
1444        unsafe { CTFontGetOpticalBoundsForGlyphs(self, glyphs, bounding_rects, count, options) }
1445    }
1446
1447    /// Calculates the advances for an array of glyphs and returns the summed advance.
1448    ///
1449    ///
1450    /// Parameter `font`: The font reference.
1451    ///
1452    ///
1453    /// Parameter `orientation`: The intended drawing orientation of the glyphs. Used to determined which glyph metrics to return.
1454    ///
1455    ///
1456    /// Parameter `glyphs`: An array of count number of glyphs.
1457    ///
1458    ///
1459    /// Parameter `advances`: An array of count number of CGSize to receive the computed glyph advances. Can be NULL, in which case only the overall advance is calculated.
1460    ///
1461    ///
1462    /// Parameter `count`: The capacity of the glyphs and advances buffers.
1463    ///
1464    ///
1465    /// Returns: This function returns the summed glyph advance of an array of glyphs. Individual glyph advances are passed back via the advances parameter. These are the ideal metrics for each glyph scaled and transformed in font space.
1466    #[doc(alias = "CTFontGetAdvancesForGlyphs")]
1467    #[cfg(all(feature = "CTFontDescriptor", feature = "objc2-core-graphics"))]
1468    #[inline]
1469    pub unsafe fn advances_for_glyphs(
1470        self: &CTFont,
1471        orientation: CTFontOrientation,
1472        glyphs: NonNull<CGGlyph>,
1473        advances: *mut CGSize,
1474        count: CFIndex,
1475    ) -> c_double {
1476        extern "C-unwind" {
1477            fn CTFontGetAdvancesForGlyphs(
1478                font: &CTFont,
1479                orientation: CTFontOrientation,
1480                glyphs: NonNull<CGGlyph>,
1481                advances: *mut CGSize,
1482                count: CFIndex,
1483            ) -> c_double;
1484        }
1485        unsafe { CTFontGetAdvancesForGlyphs(self, orientation, glyphs, advances, count) }
1486    }
1487
1488    /// Calculates the offset from the default (horizontal) origin to the vertical origin for an array of glyphs.
1489    ///
1490    ///
1491    /// Parameter `font`: The font reference.
1492    ///
1493    ///
1494    /// Parameter `glyphs`: An array of count number of glyphs.
1495    ///
1496    ///
1497    /// Parameter `translations`: An array of count number of CGSize to receive the computed origin offsets.
1498    ///
1499    ///
1500    /// Parameter `count`: The capacity of the glyphs and translations buffers.
1501    #[doc(alias = "CTFontGetVerticalTranslationsForGlyphs")]
1502    #[cfg(feature = "objc2-core-graphics")]
1503    #[inline]
1504    pub unsafe fn vertical_translations_for_glyphs(
1505        self: &CTFont,
1506        glyphs: NonNull<CGGlyph>,
1507        translations: NonNull<CGSize>,
1508        count: CFIndex,
1509    ) {
1510        extern "C-unwind" {
1511            fn CTFontGetVerticalTranslationsForGlyphs(
1512                font: &CTFont,
1513                glyphs: NonNull<CGGlyph>,
1514                translations: NonNull<CGSize>,
1515                count: CFIndex,
1516            );
1517        }
1518        unsafe { CTFontGetVerticalTranslationsForGlyphs(self, glyphs, translations, count) }
1519    }
1520
1521    /// Creates a path for the specified glyph.
1522    ///
1523    ///
1524    /// Creates a path from the outlines of the glyph for the specified font. The path will reflect the font point size, matrix, and transform parameter, in that order. The transform parameter will most commonly be used to provide a translation to the desired glyph origin.
1525    ///
1526    ///
1527    /// Parameter `font`: The font reference.
1528    ///
1529    ///
1530    /// Parameter `glyph`: The glyph.
1531    ///
1532    ///
1533    /// Parameter `matrix`: An affine transform applied to the path. Can be NULL, in which case CGAffineTransformIdentity will be used.
1534    ///
1535    ///
1536    /// Returns: A retained CGPath reference containing the glyph outlines or NULL if there is no such glyph or it has no outline.
1537    #[doc(alias = "CTFontCreatePathForGlyph")]
1538    #[cfg(feature = "objc2-core-graphics")]
1539    #[inline]
1540    pub unsafe fn path_for_glyph(
1541        self: &CTFont,
1542        glyph: CGGlyph,
1543        matrix: *const CGAffineTransform,
1544    ) -> Option<CFRetained<CGPath>> {
1545        extern "C-unwind" {
1546            fn CTFontCreatePathForGlyph(
1547                font: &CTFont,
1548                glyph: CGGlyph,
1549                matrix: *const CGAffineTransform,
1550            ) -> Option<NonNull<CGPath>>;
1551        }
1552        let ret = unsafe { CTFontCreatePathForGlyph(self, glyph, matrix) };
1553        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1554    }
1555}
1556
1557extern "C" {
1558    /// kCTFontVariationAxisIdentifierKey
1559    ///
1560    /// Key to get the variation axis identifier.
1561    ///
1562    /// This key is used with a variation axis dictionary to get the axis identifier value as a CFNumberRef.
1563    ///
1564    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationaxisidentifierkey?language=objc)
1565    pub static kCTFontVariationAxisIdentifierKey: &'static CFString;
1566}
1567
1568extern "C" {
1569    /// kCTFontVariationAxisMinimumValueKey
1570    ///
1571    /// Key to get the variation axis minimum value.
1572    ///
1573    /// This key is used with a variation axis dictionary to get the minimum axis value as a CFNumberRef.
1574    ///
1575    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationaxisminimumvaluekey?language=objc)
1576    pub static kCTFontVariationAxisMinimumValueKey: &'static CFString;
1577}
1578
1579extern "C" {
1580    /// kCTFontVariationAxisMaximumValueKey
1581    ///
1582    /// Key to get the variation axis maximum value.
1583    ///
1584    /// This key is used with a variation axis dictionary to get the maximum axis value as a CFNumberRef.
1585    ///
1586    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationaxismaximumvaluekey?language=objc)
1587    pub static kCTFontVariationAxisMaximumValueKey: &'static CFString;
1588}
1589
1590extern "C" {
1591    /// kCTFontVariationAxisDefaultValueKey
1592    ///
1593    /// Key to get the variation axis default value.
1594    ///
1595    /// This key is used with a variation axis dictionary to get the default axis value as a CFNumberRef.
1596    ///
1597    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationaxisdefaultvaluekey?language=objc)
1598    pub static kCTFontVariationAxisDefaultValueKey: &'static CFString;
1599}
1600
1601extern "C" {
1602    /// kCTFontVariationAxisNameKey
1603    ///
1604    /// Key to get the variation axis name string.
1605    ///
1606    /// This key is used with a variation axis dictionary to get the variation axis name.
1607    ///
1608    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationaxisnamekey?language=objc)
1609    pub static kCTFontVariationAxisNameKey: &'static CFString;
1610}
1611
1612extern "C" {
1613    /// kCTFontVariationAxisHiddenKey
1614    ///
1615    /// Key to get the hidden axis flag.
1616    ///
1617    /// This key contains a CFBoolean value that is true when the font designer recommends the axis not be exposed directly to end users in application interfaces.
1618    ///
1619    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontvariationaxishiddenkey?language=objc)
1620    pub static kCTFontVariationAxisHiddenKey: &'static CFString;
1621}
1622
1623impl CTFont {
1624    /// Returns an array of variation axis dictionaries.
1625    ///
1626    /// Each variation axis dictionary contains the five kCTFontVariationAxis* keys above, and kCTFontVariationAxisNameKey values will be localized when supported by the font.
1627    ///
1628    ///
1629    /// Parameter `font`: The font reference.
1630    ///
1631    ///
1632    /// Returns: An array of variation axis dictionaries or null if the font does not support variations.
1633    #[doc(alias = "CTFontCopyVariationAxes")]
1634    #[inline]
1635    pub unsafe fn variation_axes(self: &CTFont) -> Option<CFRetained<CFArray>> {
1636        extern "C-unwind" {
1637            fn CTFontCopyVariationAxes(font: &CTFont) -> Option<NonNull<CFArray>>;
1638        }
1639        let ret = unsafe { CTFontCopyVariationAxes(self) };
1640        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1641    }
1642
1643    /// Returns a variation dictionary.
1644    ///
1645    /// This function describes the current configuration of a variation font: a dictionary of number values with variation identifier number keys. As of macOS 10.12 and iOS 10.0, only non-default values (as determined by the variation axis) are returned.
1646    ///
1647    ///
1648    /// Parameter `font`: The font reference.
1649    ///
1650    ///
1651    /// Returns: This function returns a variation dictionary or null if the font does not support variations.
1652    ///
1653    ///
1654    /// See also: kCTFontVariationAxisIdentifierKey
1655    ///
1656    /// See also: kCTFontVariationAxisDefaultValueKey
1657    #[doc(alias = "CTFontCopyVariation")]
1658    #[inline]
1659    pub unsafe fn variation(self: &CTFont) -> Option<CFRetained<CFDictionary>> {
1660        extern "C-unwind" {
1661            fn CTFontCopyVariation(font: &CTFont) -> Option<NonNull<CFDictionary>>;
1662        }
1663        let ret = unsafe { CTFontCopyVariation(self) };
1664        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1665    }
1666}
1667
1668extern "C" {
1669    /// kCTFontOpenTypeFeatureTag
1670    ///
1671    /// Key to get the OpenType feature tag.
1672    ///
1673    /// This key can be used with a font feature dictionary to get the tag as a CFStringRef.
1674    ///
1675    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontopentypefeaturetag?language=objc)
1676    pub static kCTFontOpenTypeFeatureTag: &'static CFString;
1677}
1678
1679extern "C" {
1680    /// kCTFontOpenTypeFeatureValue
1681    ///
1682    /// Key to get the OpenType feature value.
1683    ///
1684    /// This key can be used with a font feature dictionary to get the value as a CFNumberRef.
1685    ///
1686    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontopentypefeaturevalue?language=objc)
1687    pub static kCTFontOpenTypeFeatureValue: &'static CFString;
1688}
1689
1690extern "C" {
1691    /// kCTFontFeatureTypeIdentifierKey
1692    ///
1693    /// Key to get the font feature type value.
1694    ///
1695    /// This key can be used with a font feature dictionary to get the type identifier as a CFNumberRef.
1696    ///
1697    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturetypeidentifierkey?language=objc)
1698    pub static kCTFontFeatureTypeIdentifierKey: &'static CFString;
1699}
1700
1701extern "C" {
1702    /// kCTFontFeatureTypeNameKey
1703    ///
1704    /// Key to get the font feature name.
1705    ///
1706    /// This key can be used with a font feature dictionary to get the localized type name string as a CFString.
1707    ///
1708    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturetypenamekey?language=objc)
1709    pub static kCTFontFeatureTypeNameKey: &'static CFString;
1710}
1711
1712extern "C" {
1713    /// kCTFontFeatureTypeExclusiveKey
1714    ///
1715    /// Key to get the font feature exclusive setting.
1716    ///
1717    /// This key can be used with a font feature dictionary to get the the exclusive setting of the feature as a CFBoolean. The value associated with this key indicates whether the feature selectors associated with this type should be mutually exclusive.
1718    ///
1719    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturetypeexclusivekey?language=objc)
1720    pub static kCTFontFeatureTypeExclusiveKey: &'static CFString;
1721}
1722
1723extern "C" {
1724    /// kCTFontFeatureTypeSelectorsKey
1725    ///
1726    /// Key to get the font feature selectors.
1727    ///
1728    /// This key can be used with a font feature dictionary to get the array of font feature selectors as a CFArrayRef. This is an array of selector dictionaries that contain the values for the following selector keys.
1729    ///
1730    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturetypeselectorskey?language=objc)
1731    pub static kCTFontFeatureTypeSelectorsKey: &'static CFString;
1732}
1733
1734extern "C" {
1735    /// kCTFontFeatureSelectorIdentifierKey
1736    ///
1737    /// Key to get the font feature selector identifier.
1738    ///
1739    /// This key can be used with a selector dictionary corresponding to a feature type to obtain the selector identifier value as a CFNumberRef.
1740    ///
1741    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeatureselectoridentifierkey?language=objc)
1742    pub static kCTFontFeatureSelectorIdentifierKey: &'static CFString;
1743}
1744
1745extern "C" {
1746    /// kCTFontFeatureSelectorNameKey
1747    ///
1748    /// Key to get the font feature selector name.
1749    ///
1750    /// This key is used with a selector dictionary to get the localized name string for the selector as a CFStringRef.
1751    ///
1752    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeatureselectornamekey?language=objc)
1753    pub static kCTFontFeatureSelectorNameKey: &'static CFString;
1754}
1755
1756extern "C" {
1757    /// kCTFontFeatureSelectorDefaultKey
1758    ///
1759    /// Key to get the font feature selector default setting value.
1760    ///
1761    /// This key is used with a selector dictionary to get the default indicator for the selector. This value is a CFBooleanRef which if present and true indicates that this selector is the default setting for the current feature type.
1762    ///
1763    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeatureselectordefaultkey?language=objc)
1764    pub static kCTFontFeatureSelectorDefaultKey: &'static CFString;
1765}
1766
1767extern "C" {
1768    /// kCTFontFeatureSelectorSettingKey
1769    ///
1770    /// Key to get or specify the current feature setting.
1771    ///
1772    /// This key is used with a selector dictionary to get or specify the current setting for the selector. This value is a CFBooleanRef to indicate whether this selector is on or off. If this key is not present, the default setting is used.
1773    ///
1774    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeatureselectorsettingkey?language=objc)
1775    pub static kCTFontFeatureSelectorSettingKey: &'static CFString;
1776}
1777
1778extern "C" {
1779    /// kCTFontFeatureSampleTextKey
1780    ///
1781    /// Key to get the font feature sample text.
1782    ///
1783    /// This key can be used with a font feature dictionary to get the localized sample text as a CFStringRef.
1784    ///
1785    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturesampletextkey?language=objc)
1786    pub static kCTFontFeatureSampleTextKey: &'static CFString;
1787}
1788
1789extern "C" {
1790    /// kCTFontFeatureTooltipTextKey
1791    ///
1792    /// Key to get the font feature tooltip text.
1793    ///
1794    /// This key can be used with a font feature dictionary to get the localized tooltip text as a CFStringRef.
1795    ///
1796    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfontfeaturetooltiptextkey?language=objc)
1797    pub static kCTFontFeatureTooltipTextKey: &'static CFString;
1798}
1799
1800impl CTFont {
1801    /// Returns an array of font features
1802    ///
1803    ///
1804    /// Parameter `font`: The font reference.
1805    ///
1806    ///
1807    /// Returns: This function returns an array of font feature dictionaries for the font reference.
1808    #[doc(alias = "CTFontCopyFeatures")]
1809    #[inline]
1810    pub unsafe fn features(self: &CTFont) -> Option<CFRetained<CFArray>> {
1811        extern "C-unwind" {
1812            fn CTFontCopyFeatures(font: &CTFont) -> Option<NonNull<CFArray>>;
1813        }
1814        let ret = unsafe { CTFontCopyFeatures(self) };
1815        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1816    }
1817
1818    /// Returns an array of font feature setting tuples
1819    ///
1820    ///
1821    /// A setting tuple is a dictionary of a kCTFontFeatureTypeIdentifierKey key-value pair and a kCTFontFeatureSelectorIdentifierKey key-value pair. Each tuple corresponds to an enabled non-default setting. It is the caller's responsibility to handle exclusive and non-exclusive settings as necessary.
1822    ///
1823    ///
1824    /// Parameter `font`: The font reference.
1825    ///
1826    ///
1827    /// Returns: This function returns a normalized array of font feature setting dictionaries. The array will only contain the non-default settings that should be applied to the font, or NULL if the default settings should be used.
1828    #[doc(alias = "CTFontCopyFeatureSettings")]
1829    #[inline]
1830    pub unsafe fn feature_settings(self: &CTFont) -> Option<CFRetained<CFArray>> {
1831        extern "C-unwind" {
1832            fn CTFontCopyFeatureSettings(font: &CTFont) -> Option<NonNull<CFArray>>;
1833        }
1834        let ret = unsafe { CTFontCopyFeatureSettings(self) };
1835        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1836    }
1837
1838    /// Returns a CGFontRef and attributes.
1839    ///
1840    ///
1841    /// Parameter `font`: The font reference.
1842    ///
1843    ///
1844    /// Parameter `attributes`: A pointer to a CTFontDescriptorRef to receive a font descriptor containing additional attributes. Can be NULL. Must be released by caller.
1845    ///
1846    ///
1847    /// Returns: This function returns a CGFontRef for the given font reference. Additional attributes from the font will be passed back as a font descriptor via the attributes parameter. The result must be released by the caller.
1848    #[doc(alias = "CTFontCopyGraphicsFont")]
1849    #[cfg(all(feature = "CTFontDescriptor", feature = "objc2-core-graphics"))]
1850    #[inline]
1851    pub unsafe fn graphics_font(
1852        self: &CTFont,
1853        attributes: *mut *const CTFontDescriptor,
1854    ) -> CFRetained<CGFont> {
1855        extern "C-unwind" {
1856            fn CTFontCopyGraphicsFont(
1857                font: &CTFont,
1858                attributes: *mut *const CTFontDescriptor,
1859            ) -> Option<NonNull<CGFont>>;
1860        }
1861        let ret = unsafe { CTFontCopyGraphicsFont(self, attributes) };
1862        let ret =
1863            ret.expect("function was marked as returning non-null, but actually returned NULL");
1864        unsafe { CFRetained::from_raw(ret) }
1865    }
1866
1867    /// Creates a new font reference from a CGFontRef.
1868    ///
1869    ///
1870    /// Parameter `graphicsFont`: A valid CGFontRef.
1871    ///
1872    ///
1873    /// Parameter `size`: The point size for the font reference. If 0.0 is specified, the default font size of 12.0 will be used.
1874    ///
1875    ///
1876    /// Parameter `matrix`: The transformation matrix for the font. If unspecified, the identity matrix will be used. Optional.
1877    ///
1878    ///
1879    /// Parameter `attributes`: A CTFontDescriptorRef containing additional attributes that should be matched. Optional.
1880    ///
1881    ///
1882    /// Returns: This function returns a new font reference for an existing CGFontRef with the specified size, matrix, and additional attributes.
1883    #[doc(alias = "CTFontCreateWithGraphicsFont")]
1884    #[cfg(all(feature = "CTFontDescriptor", feature = "objc2-core-graphics"))]
1885    #[inline]
1886    pub unsafe fn with_graphics_font(
1887        graphics_font: &CGFont,
1888        size: CGFloat,
1889        matrix: *const CGAffineTransform,
1890        attributes: Option<&CTFontDescriptor>,
1891    ) -> CFRetained<CTFont> {
1892        extern "C-unwind" {
1893            fn CTFontCreateWithGraphicsFont(
1894                graphics_font: &CGFont,
1895                size: CGFloat,
1896                matrix: *const CGAffineTransform,
1897                attributes: Option<&CTFontDescriptor>,
1898            ) -> Option<NonNull<CTFont>>;
1899        }
1900        let ret = unsafe { CTFontCreateWithGraphicsFont(graphics_font, size, matrix, attributes) };
1901        let ret =
1902            ret.expect("function was marked as returning non-null, but actually returned NULL");
1903        unsafe { CFRetained::from_raw(ret) }
1904    }
1905}
1906
1907/// [Apple's documentation](https://developer.apple.com/documentation/coretext/atsfontref?language=objc)
1908pub type ATSFontRef = u32;
1909
1910impl CTFont {
1911    /// Returns a font reference for the given Quickdraw instance.
1912    ///
1913    ///
1914    /// This function is provided for compatibility support between Core Text and clients needing to support Quickdraw font references.
1915    ///
1916    ///
1917    /// Parameter `name`: The Quickdraw font name. If NULL or zero length, an identifier must be specified instead.
1918    ///
1919    ///
1920    /// Parameter `identifier`: The Quickdraw font identifier. If 0, a name must be specified instead.
1921    ///
1922    ///
1923    /// Parameter `style`: The Quickdraw font style.
1924    ///
1925    ///
1926    /// Parameter `size`: The point size for the font reference. If 0.0 is specified, the default size of 12.0 is used.
1927    ///
1928    ///
1929    /// Returns: This function returns the best font instance matching the Quickdraw instance information.
1930    #[doc(alias = "CTFontCreateWithQuickdrawInstance")]
1931    #[deprecated = "Quickdraw font references are deprecated"]
1932    #[inline]
1933    pub unsafe fn with_quickdraw_instance(
1934        name: ConstStr255Param,
1935        identifier: i16,
1936        style: u8,
1937        size: CGFloat,
1938    ) -> CFRetained<CTFont> {
1939        extern "C-unwind" {
1940            fn CTFontCreateWithQuickdrawInstance(
1941                name: ConstStr255Param,
1942                identifier: i16,
1943                style: u8,
1944                size: CGFloat,
1945            ) -> Option<NonNull<CTFont>>;
1946        }
1947        let ret = unsafe { CTFontCreateWithQuickdrawInstance(name, identifier, style, size) };
1948        let ret =
1949            ret.expect("function was marked as returning non-null, but actually returned NULL");
1950        unsafe { CFRetained::from_raw(ret) }
1951    }
1952}
1953
1954/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablebase?language=objc)
1955pub const kCTFontTableBASE: c_uint = 0x42415345;
1956/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablecbdt?language=objc)
1957pub const kCTFontTableCBDT: c_uint = 0x43424454;
1958/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablecblc?language=objc)
1959pub const kCTFontTableCBLC: c_uint = 0x43424c43;
1960/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablecff?language=objc)
1961pub const kCTFontTableCFF: c_uint = 0x43464620;
1962/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablecff2?language=objc)
1963pub const kCTFontTableCFF2: c_uint = 0x43464632;
1964/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablecolr?language=objc)
1965pub const kCTFontTableCOLR: c_uint = 0x434f4c52;
1966/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablecpal?language=objc)
1967pub const kCTFontTableCPAL: c_uint = 0x4350414c;
1968/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttabledsig?language=objc)
1969pub const kCTFontTableDSIG: c_uint = 0x44534947;
1970/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableebdt?language=objc)
1971pub const kCTFontTableEBDT: c_uint = 0x45424454;
1972/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableeblc?language=objc)
1973pub const kCTFontTableEBLC: c_uint = 0x45424c43;
1974/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableebsc?language=objc)
1975pub const kCTFontTableEBSC: c_uint = 0x45425343;
1976/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablegdef?language=objc)
1977pub const kCTFontTableGDEF: c_uint = 0x47444546;
1978/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablegpos?language=objc)
1979pub const kCTFontTableGPOS: c_uint = 0x47504f53;
1980/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablegsub?language=objc)
1981pub const kCTFontTableGSUB: c_uint = 0x47535542;
1982/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablehvar?language=objc)
1983pub const kCTFontTableHVAR: c_uint = 0x48564152;
1984/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablejstf?language=objc)
1985pub const kCTFontTableJSTF: c_uint = 0x4a535446;
1986/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableltsh?language=objc)
1987pub const kCTFontTableLTSH: c_uint = 0x4c545348;
1988/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablemath?language=objc)
1989pub const kCTFontTableMATH: c_uint = 0x4d415448;
1990/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablemerg?language=objc)
1991pub const kCTFontTableMERG: c_uint = 0x4d455247;
1992/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablemvar?language=objc)
1993pub const kCTFontTableMVAR: c_uint = 0x4d564152;
1994/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableos2?language=objc)
1995pub const kCTFontTableOS2: c_uint = 0x4f532f32;
1996/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablepclt?language=objc)
1997pub const kCTFontTablePCLT: c_uint = 0x50434c54;
1998/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablestat?language=objc)
1999pub const kCTFontTableSTAT: c_uint = 0x53544154;
2000/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablesvg?language=objc)
2001pub const kCTFontTableSVG: c_uint = 0x53564720;
2002/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablevdmx?language=objc)
2003pub const kCTFontTableVDMX: c_uint = 0x56444d58;
2004/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablevorg?language=objc)
2005pub const kCTFontTableVORG: c_uint = 0x564f5247;
2006/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablevvar?language=objc)
2007pub const kCTFontTableVVAR: c_uint = 0x56564152;
2008/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablezapf?language=objc)
2009pub const kCTFontTableZapf: c_uint = 0x5a617066;
2010/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableacnt?language=objc)
2011pub const kCTFontTableAcnt: c_uint = 0x61636e74;
2012/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableankr?language=objc)
2013pub const kCTFontTableAnkr: c_uint = 0x616e6b72;
2014/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableavar?language=objc)
2015pub const kCTFontTableAvar: c_uint = 0x61766172;
2016/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablebdat?language=objc)
2017pub const kCTFontTableBdat: c_uint = 0x62646174;
2018/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablebhed?language=objc)
2019pub const kCTFontTableBhed: c_uint = 0x62686564;
2020/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablebloc?language=objc)
2021pub const kCTFontTableBloc: c_uint = 0x626c6f63;
2022/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablebsln?language=objc)
2023pub const kCTFontTableBsln: c_uint = 0x62736c6e;
2024/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablecidg?language=objc)
2025pub const kCTFontTableCidg: c_uint = 0x63696467;
2026/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablecmap?language=objc)
2027pub const kCTFontTableCmap: c_uint = 0x636d6170;
2028/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablecvar?language=objc)
2029pub const kCTFontTableCvar: c_uint = 0x63766172;
2030/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablecvt?language=objc)
2031pub const kCTFontTableCvt: c_uint = 0x63767420;
2032/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablefdsc?language=objc)
2033pub const kCTFontTableFdsc: c_uint = 0x66647363;
2034/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablefeat?language=objc)
2035pub const kCTFontTableFeat: c_uint = 0x66656174;
2036/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablefmtx?language=objc)
2037pub const kCTFontTableFmtx: c_uint = 0x666d7478;
2038/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablefond?language=objc)
2039pub const kCTFontTableFond: c_uint = 0x666f6e64;
2040/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablefpgm?language=objc)
2041pub const kCTFontTableFpgm: c_uint = 0x6670676d;
2042/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablefvar?language=objc)
2043pub const kCTFontTableFvar: c_uint = 0x66766172;
2044/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablegasp?language=objc)
2045pub const kCTFontTableGasp: c_uint = 0x67617370;
2046/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableglyf?language=objc)
2047pub const kCTFontTableGlyf: c_uint = 0x676c7966;
2048/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablegvar?language=objc)
2049pub const kCTFontTableGvar: c_uint = 0x67766172;
2050/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablehdmx?language=objc)
2051pub const kCTFontTableHdmx: c_uint = 0x68646d78;
2052/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablehead?language=objc)
2053pub const kCTFontTableHead: c_uint = 0x68656164;
2054/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablehhea?language=objc)
2055pub const kCTFontTableHhea: c_uint = 0x68686561;
2056/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablehmtx?language=objc)
2057pub const kCTFontTableHmtx: c_uint = 0x686d7478;
2058/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablehsty?language=objc)
2059pub const kCTFontTableHsty: c_uint = 0x68737479;
2060/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablejust?language=objc)
2061pub const kCTFontTableJust: c_uint = 0x6a757374;
2062/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablekern?language=objc)
2063pub const kCTFontTableKern: c_uint = 0x6b65726e;
2064/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablekerx?language=objc)
2065pub const kCTFontTableKerx: c_uint = 0x6b657278;
2066/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablelcar?language=objc)
2067pub const kCTFontTableLcar: c_uint = 0x6c636172;
2068/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableloca?language=objc)
2069pub const kCTFontTableLoca: c_uint = 0x6c6f6361;
2070/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableltag?language=objc)
2071pub const kCTFontTableLtag: c_uint = 0x6c746167;
2072/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablemaxp?language=objc)
2073pub const kCTFontTableMaxp: c_uint = 0x6d617870;
2074/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablemeta?language=objc)
2075pub const kCTFontTableMeta: c_uint = 0x6d657461;
2076/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablemort?language=objc)
2077pub const kCTFontTableMort: c_uint = 0x6d6f7274;
2078/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablemorx?language=objc)
2079pub const kCTFontTableMorx: c_uint = 0x6d6f7278;
2080/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablename?language=objc)
2081pub const kCTFontTableName: c_uint = 0x6e616d65;
2082/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableopbd?language=objc)
2083pub const kCTFontTableOpbd: c_uint = 0x6f706264;
2084/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablepost?language=objc)
2085pub const kCTFontTablePost: c_uint = 0x706f7374;
2086/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableprep?language=objc)
2087pub const kCTFontTablePrep: c_uint = 0x70726570;
2088/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttableprop?language=objc)
2089pub const kCTFontTableProp: c_uint = 0x70726f70;
2090/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablesbit?language=objc)
2091pub const kCTFontTableSbit: c_uint = 0x73626974;
2092/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablesbix?language=objc)
2093pub const kCTFontTableSbix: c_uint = 0x73626978;
2094/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttabletrak?language=objc)
2095pub const kCTFontTableTrak: c_uint = 0x7472616b;
2096/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablevhea?language=objc)
2097pub const kCTFontTableVhea: c_uint = 0x76686561;
2098/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablevmtx?language=objc)
2099pub const kCTFontTableVmtx: c_uint = 0x766d7478;
2100/// [Apple's documentation](https://developer.apple.com/documentation/coretext/kctfonttablexref?language=objc)
2101pub const kCTFontTableXref: c_uint = 0x78726566;
2102
2103/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfonttabletag?language=objc)
2104pub type CTFontTableTag = FourCharCode;
2105
2106/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctfonttableoptions?language=objc)
2107// NS_OPTIONS
2108#[repr(transparent)]
2109#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2110pub struct CTFontTableOptions(pub u32);
2111bitflags::bitflags! {
2112    impl CTFontTableOptions: u32 {
2113        #[doc(alias = "kCTFontTableOptionNoOptions")]
2114        const NoOptions = 0;
2115        #[doc(alias = "kCTFontTableOptionExcludeSynthetic")]
2116#[deprecated = "Unsupported"]
2117        const ExcludeSynthetic = 1<<0;
2118    }
2119}
2120
2121#[cfg(feature = "objc2")]
2122unsafe impl Encode for CTFontTableOptions {
2123    const ENCODING: Encoding = u32::ENCODING;
2124}
2125
2126#[cfg(feature = "objc2")]
2127unsafe impl RefEncode for CTFontTableOptions {
2128    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2129}
2130
2131impl CTFont {
2132    /// Returns an array of font table tags.
2133    ///
2134    ///
2135    /// Parameter `font`: The font reference.
2136    ///
2137    ///
2138    /// Parameter `options`: The options used when copying font tables.
2139    ///
2140    ///
2141    /// Returns: This function returns an array of CTFontTableTag values for the given font and the supplied options. The returned set will contain unboxed values, which may be extracted like so:
2142    /// <code>
2143    /// CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tags, index);
2144    /// </code>
2145    #[doc(alias = "CTFontCopyAvailableTables")]
2146    #[inline]
2147    pub unsafe fn available_tables(
2148        self: &CTFont,
2149        options: CTFontTableOptions,
2150    ) -> Option<CFRetained<CFArray>> {
2151        extern "C-unwind" {
2152            fn CTFontCopyAvailableTables(
2153                font: &CTFont,
2154                options: CTFontTableOptions,
2155            ) -> Option<NonNull<CFArray>>;
2156        }
2157        let ret = unsafe { CTFontCopyAvailableTables(self, options) };
2158        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2159    }
2160
2161    /// Determine whether a table is present in a font.
2162    ///
2163    /// This is a convenience function to avoid requesting an array of table tags or any table data. It behaves according as if using `kCTFontTableOptionNoOptions`.
2164    ///
2165    ///
2166    /// Parameter `font`: The font reference.
2167    ///
2168    ///
2169    /// Parameter `tag`: The font table identifier as a CTFontTableTag.
2170    ///
2171    ///
2172    /// Returns: Returns true if the call was successful and the requested table is present.
2173    #[doc(alias = "CTFontHasTable")]
2174    #[inline]
2175    pub unsafe fn has_table(self: &CTFont, tag: CTFontTableTag) -> bool {
2176        extern "C-unwind" {
2177            fn CTFontHasTable(font: &CTFont, tag: CTFontTableTag) -> bool;
2178        }
2179        unsafe { CTFontHasTable(self, tag) }
2180    }
2181
2182    /// Returns a reference to the font table data.
2183    ///
2184    ///
2185    /// Parameter `font`: The font reference.
2186    ///
2187    ///
2188    /// Parameter `table`: The font table identifier as a CTFontTableTag.
2189    ///
2190    ///
2191    /// Parameter `options`: The options used when copying font table.
2192    ///
2193    ///
2194    /// Returns: This function returns a retained reference to the font table data as CFDataRef or NULL if the table is not present.
2195    #[doc(alias = "CTFontCopyTable")]
2196    #[inline]
2197    pub unsafe fn table(
2198        self: &CTFont,
2199        table: CTFontTableTag,
2200        options: CTFontTableOptions,
2201    ) -> Option<CFRetained<CFData>> {
2202        extern "C-unwind" {
2203            fn CTFontCopyTable(
2204                font: &CTFont,
2205                table: CTFontTableTag,
2206                options: CTFontTableOptions,
2207            ) -> Option<NonNull<CFData>>;
2208        }
2209        let ret = unsafe { CTFontCopyTable(self, table, options) };
2210        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2211    }
2212
2213    /// Renders the given glyphs from the CTFont at the given positions in the CGContext.
2214    ///
2215    /// This function will modify the CGContext's font, text size, and text matrix if specified in the CTFont. These attributes will not be restored.
2216    /// The given glyphs should be the result of proper Unicode text layout operations (such as CTLine). Results from CTFontGetGlyphsForCharacters (or similar APIs) do not perform any Unicode text layout.
2217    ///
2218    ///
2219    /// Parameter `font`: The font to render glyphs from. If the font has a size or matrix attribute, the CGContext will be set with these values.
2220    ///
2221    ///
2222    /// Parameter `glyphs`: The glyphs to be rendered. See above discussion of how the glyphs should be derived.
2223    ///
2224    ///
2225    /// Parameter `positions`: The positions (origins) for each glyph. The positions are in user space. The number of positions passed in must be equivalent to the number of glyphs.
2226    ///
2227    ///
2228    /// Parameter `count`: The number of glyphs to be rendered from the glyphs array.
2229    ///
2230    ///
2231    /// Parameter `context`: CGContext used to render the glyphs.
2232    #[doc(alias = "CTFontDrawGlyphs")]
2233    #[cfg(feature = "objc2-core-graphics")]
2234    #[inline]
2235    pub unsafe fn draw_glyphs(
2236        self: &CTFont,
2237        glyphs: NonNull<CGGlyph>,
2238        positions: NonNull<CGPoint>,
2239        count: usize,
2240        context: &CGContext,
2241    ) {
2242        extern "C-unwind" {
2243            fn CTFontDrawGlyphs(
2244                font: &CTFont,
2245                glyphs: NonNull<CGGlyph>,
2246                positions: NonNull<CGPoint>,
2247                count: usize,
2248                context: &CGContext,
2249            );
2250        }
2251        unsafe { CTFontDrawGlyphs(self, glyphs, positions, count, context) }
2252    }
2253
2254    /// Returns caret positions within a glyph.
2255    ///
2256    /// This function is used to obtain caret positions for a specific glyph.
2257    /// The return value is the max number of positions possible, and the function
2258    /// will populate the caller's positions buffer with available positions if possible.
2259    /// This function may not be able to produce positions if the font does not
2260    /// have the appropriate data, in which case it will return 0.
2261    ///
2262    ///
2263    /// Parameter `font`: The font reference.
2264    ///
2265    ///
2266    /// Parameter `glyph`: The glyph.
2267    ///
2268    ///
2269    /// Parameter `positions`: A buffer of at least maxPositions to receive the ligature caret positions for
2270    /// the glyph.
2271    ///
2272    ///
2273    /// Parameter `maxPositions`: The maximum number of positions to return.
2274    ///
2275    ///
2276    /// Returns: Returns the number of caret positions for the specified glyph.
2277    #[doc(alias = "CTFontGetLigatureCaretPositions")]
2278    #[cfg(feature = "objc2-core-graphics")]
2279    #[inline]
2280    pub unsafe fn ligature_caret_positions(
2281        self: &CTFont,
2282        glyph: CGGlyph,
2283        positions: *mut CGFloat,
2284        max_positions: CFIndex,
2285    ) -> CFIndex {
2286        extern "C-unwind" {
2287            fn CTFontGetLigatureCaretPositions(
2288                font: &CTFont,
2289                glyph: CGGlyph,
2290                positions: *mut CGFloat,
2291                max_positions: CFIndex,
2292            ) -> CFIndex;
2293        }
2294        unsafe { CTFontGetLigatureCaretPositions(self, glyph, positions, max_positions) }
2295    }
2296}
2297
2298extern "C" {
2299    /// kCTBaselineClassRoman
2300    ///
2301    ///
2302    /// Key to reference the Roman baseline class.
2303    ///
2304    ///
2305    /// This key can be used with a baseline info dictionary to offset to the Roman baseline as a CFNumberRef float. It can also be used as the value for kCTBaselineClassAttributeName.
2306    ///
2307    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctbaselineclassroman?language=objc)
2308    pub static kCTBaselineClassRoman: &'static CFString;
2309}
2310
2311extern "C" {
2312    /// kCTBaselineClassIdeographicCentered
2313    ///
2314    ///
2315    /// Key to reference the Ideographic Centered baseline class.
2316    ///
2317    ///
2318    /// This key can be used with a baseline info dictionary to offset to the Ideographic Centered baseline as a CFNumberRef float. It can also be used as the value for kCTBaselineClassAttributeName.
2319    ///
2320    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctbaselineclassideographiccentered?language=objc)
2321    pub static kCTBaselineClassIdeographicCentered: &'static CFString;
2322}
2323
2324extern "C" {
2325    /// kCTBaselineClassIdeographicLow
2326    ///
2327    ///
2328    /// Key to reference the Ideographic Low baseline class.
2329    ///
2330    ///
2331    /// This key can be used with a baseline info dictionary to offset to the Ideographic Low baseline as a CFNumberRef float. It can also be used as the value for kCTBaselineClassAttributeName.
2332    ///
2333    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctbaselineclassideographiclow?language=objc)
2334    pub static kCTBaselineClassIdeographicLow: &'static CFString;
2335}
2336
2337extern "C" {
2338    /// kCTBaselineClassIdeographicHigh
2339    ///
2340    ///
2341    /// Key to reference the Ideographic High baseline class.
2342    ///
2343    ///
2344    /// This key can be used with a baseline info dictionary to offset to the Ideographic High baseline as a CFNumberRef float. It can also be used as the value for kCTBaselineClassAttributeName.
2345    ///
2346    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctbaselineclassideographichigh?language=objc)
2347    pub static kCTBaselineClassIdeographicHigh: &'static CFString;
2348}
2349
2350extern "C" {
2351    /// kCTBaselineClassHanging
2352    ///
2353    ///
2354    /// Key to reference the Hanging baseline class.
2355    ///
2356    ///
2357    /// This key can be used with a baseline info dictionary to offset to the Hanging baseline as a CFNumberRef float. It can also be used as the value for kCTBaselineClassAttributeName.
2358    ///
2359    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctbaselineclasshanging?language=objc)
2360    pub static kCTBaselineClassHanging: &'static CFString;
2361}
2362
2363extern "C" {
2364    /// kCTBaselineClassMath
2365    ///
2366    ///
2367    /// Key to reference the Math baseline class.
2368    ///
2369    ///
2370    /// This key can be used with a baseline info dictionary to offset to the Math baseline as a CFNumberRef float. It can also be used as the value for kCTBaselineClassAttributeName.
2371    ///
2372    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctbaselineclassmath?language=objc)
2373    pub static kCTBaselineClassMath: &'static CFString;
2374}
2375
2376extern "C" {
2377    /// kCTBaselineReferenceFont
2378    ///
2379    ///
2380    /// Key to reference a font for the reference baseline.
2381    ///
2382    ///
2383    /// This key can be used to specify a font for the reference baseline. The value is a CTFontRef or the kCTBaselineOriginalFont constant.
2384    ///
2385    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctbaselinereferencefont?language=objc)
2386    pub static kCTBaselineReferenceFont: &'static CFString;
2387}
2388
2389extern "C" {
2390    /// kCTBaselineOriginalFont
2391    ///
2392    ///
2393    /// Use the original font for setting the reference baseline.
2394    ///
2395    ///
2396    /// This constant can be used as the value for kCTBaselineReferenceFont to specify that the original font should be used for the reference baseline.
2397    ///
2398    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctbaselineoriginalfont?language=objc)
2399    pub static kCTBaselineOriginalFont: &'static CFString;
2400}
2401
2402impl CTFont {
2403    #[doc(alias = "CTFontGetTypographicBoundsForAdaptiveImageProvider")]
2404    #[cfg(all(feature = "CTRunDelegate", feature = "objc2"))]
2405    #[inline]
2406    pub unsafe fn typographic_bounds_for_adaptive_image_provider(
2407        self: &CTFont,
2408        provider: Option<&ProtocolObject<dyn CTAdaptiveImageProviding>>,
2409    ) -> CGRect {
2410        extern "C-unwind" {
2411            fn CTFontGetTypographicBoundsForAdaptiveImageProvider(
2412                font: &CTFont,
2413                provider: Option<&ProtocolObject<dyn CTAdaptiveImageProviding>>,
2414            ) -> CGRect;
2415        }
2416        unsafe { CTFontGetTypographicBoundsForAdaptiveImageProvider(self, provider) }
2417    }
2418
2419    #[doc(alias = "CTFontDrawImageFromAdaptiveImageProviderAtPoint")]
2420    #[cfg(all(
2421        feature = "CTRunDelegate",
2422        feature = "objc2",
2423        feature = "objc2-core-graphics"
2424    ))]
2425    #[inline]
2426    pub unsafe fn draw_image_from_adaptive_image_provider_at_point(
2427        self: &CTFont,
2428        provider: &ProtocolObject<dyn CTAdaptiveImageProviding>,
2429        point: CGPoint,
2430        context: &CGContext,
2431    ) {
2432        extern "C-unwind" {
2433            fn CTFontDrawImageFromAdaptiveImageProviderAtPoint(
2434                font: &CTFont,
2435                provider: &ProtocolObject<dyn CTAdaptiveImageProviding>,
2436                point: CGPoint,
2437                context: &CGContext,
2438            );
2439        }
2440        unsafe { CTFontDrawImageFromAdaptiveImageProviderAtPoint(self, provider, point, context) }
2441    }
2442}
2443
2444#[deprecated = "renamed to `CTFont::with_name`"]
2445#[inline]
2446pub unsafe extern "C-unwind" fn CTFontCreateWithName(
2447    name: &CFString,
2448    size: CGFloat,
2449    matrix: *const CGAffineTransform,
2450) -> CFRetained<CTFont> {
2451    extern "C-unwind" {
2452        fn CTFontCreateWithName(
2453            name: &CFString,
2454            size: CGFloat,
2455            matrix: *const CGAffineTransform,
2456        ) -> Option<NonNull<CTFont>>;
2457    }
2458    let ret = unsafe { CTFontCreateWithName(name, size, matrix) };
2459    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2460    unsafe { CFRetained::from_raw(ret) }
2461}
2462
2463#[cfg(feature = "CTFontDescriptor")]
2464#[deprecated = "renamed to `CTFont::with_font_descriptor`"]
2465#[inline]
2466pub unsafe extern "C-unwind" fn CTFontCreateWithFontDescriptor(
2467    descriptor: &CTFontDescriptor,
2468    size: CGFloat,
2469    matrix: *const CGAffineTransform,
2470) -> CFRetained<CTFont> {
2471    extern "C-unwind" {
2472        fn CTFontCreateWithFontDescriptor(
2473            descriptor: &CTFontDescriptor,
2474            size: CGFloat,
2475            matrix: *const CGAffineTransform,
2476        ) -> Option<NonNull<CTFont>>;
2477    }
2478    let ret = unsafe { CTFontCreateWithFontDescriptor(descriptor, size, matrix) };
2479    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2480    unsafe { CFRetained::from_raw(ret) }
2481}
2482
2483#[deprecated = "renamed to `CTFont::with_name_and_options`"]
2484#[inline]
2485pub unsafe extern "C-unwind" fn CTFontCreateWithNameAndOptions(
2486    name: &CFString,
2487    size: CGFloat,
2488    matrix: *const CGAffineTransform,
2489    options: CTFontOptions,
2490) -> CFRetained<CTFont> {
2491    extern "C-unwind" {
2492        fn CTFontCreateWithNameAndOptions(
2493            name: &CFString,
2494            size: CGFloat,
2495            matrix: *const CGAffineTransform,
2496            options: CTFontOptions,
2497        ) -> Option<NonNull<CTFont>>;
2498    }
2499    let ret = unsafe { CTFontCreateWithNameAndOptions(name, size, matrix, options) };
2500    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2501    unsafe { CFRetained::from_raw(ret) }
2502}
2503
2504#[cfg(feature = "CTFontDescriptor")]
2505#[deprecated = "renamed to `CTFont::with_font_descriptor_and_options`"]
2506#[inline]
2507pub unsafe extern "C-unwind" fn CTFontCreateWithFontDescriptorAndOptions(
2508    descriptor: &CTFontDescriptor,
2509    size: CGFloat,
2510    matrix: *const CGAffineTransform,
2511    options: CTFontOptions,
2512) -> CFRetained<CTFont> {
2513    extern "C-unwind" {
2514        fn CTFontCreateWithFontDescriptorAndOptions(
2515            descriptor: &CTFontDescriptor,
2516            size: CGFloat,
2517            matrix: *const CGAffineTransform,
2518            options: CTFontOptions,
2519        ) -> Option<NonNull<CTFont>>;
2520    }
2521    let ret =
2522        unsafe { CTFontCreateWithFontDescriptorAndOptions(descriptor, size, matrix, options) };
2523    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2524    unsafe { CFRetained::from_raw(ret) }
2525}
2526
2527#[deprecated = "renamed to `CTFont::new_ui_font_for_language`"]
2528#[inline]
2529pub unsafe extern "C-unwind" fn CTFontCreateUIFontForLanguage(
2530    ui_type: CTFontUIFontType,
2531    size: CGFloat,
2532    language: Option<&CFString>,
2533) -> Option<CFRetained<CTFont>> {
2534    extern "C-unwind" {
2535        fn CTFontCreateUIFontForLanguage(
2536            ui_type: CTFontUIFontType,
2537            size: CGFloat,
2538            language: Option<&CFString>,
2539        ) -> Option<NonNull<CTFont>>;
2540    }
2541    let ret = unsafe { CTFontCreateUIFontForLanguage(ui_type, size, language) };
2542    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2543}
2544
2545#[cfg(feature = "CTFontDescriptor")]
2546#[deprecated = "renamed to `CTFont::copy_with_attributes`"]
2547#[inline]
2548pub unsafe extern "C-unwind" fn CTFontCreateCopyWithAttributes(
2549    font: &CTFont,
2550    size: CGFloat,
2551    matrix: *const CGAffineTransform,
2552    attributes: Option<&CTFontDescriptor>,
2553) -> CFRetained<CTFont> {
2554    extern "C-unwind" {
2555        fn CTFontCreateCopyWithAttributes(
2556            font: &CTFont,
2557            size: CGFloat,
2558            matrix: *const CGAffineTransform,
2559            attributes: Option<&CTFontDescriptor>,
2560        ) -> Option<NonNull<CTFont>>;
2561    }
2562    let ret = unsafe { CTFontCreateCopyWithAttributes(font, size, matrix, attributes) };
2563    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2564    unsafe { CFRetained::from_raw(ret) }
2565}
2566
2567#[cfg(feature = "CTFontTraits")]
2568#[deprecated = "renamed to `CTFont::copy_with_symbolic_traits`"]
2569#[inline]
2570pub unsafe extern "C-unwind" fn CTFontCreateCopyWithSymbolicTraits(
2571    font: &CTFont,
2572    size: CGFloat,
2573    matrix: *const CGAffineTransform,
2574    sym_trait_value: CTFontSymbolicTraits,
2575    sym_trait_mask: CTFontSymbolicTraits,
2576) -> Option<CFRetained<CTFont>> {
2577    extern "C-unwind" {
2578        fn CTFontCreateCopyWithSymbolicTraits(
2579            font: &CTFont,
2580            size: CGFloat,
2581            matrix: *const CGAffineTransform,
2582            sym_trait_value: CTFontSymbolicTraits,
2583            sym_trait_mask: CTFontSymbolicTraits,
2584        ) -> Option<NonNull<CTFont>>;
2585    }
2586    let ret = unsafe {
2587        CTFontCreateCopyWithSymbolicTraits(font, size, matrix, sym_trait_value, sym_trait_mask)
2588    };
2589    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2590}
2591
2592#[deprecated = "renamed to `CTFont::copy_with_family`"]
2593#[inline]
2594pub unsafe extern "C-unwind" fn CTFontCreateCopyWithFamily(
2595    font: &CTFont,
2596    size: CGFloat,
2597    matrix: *const CGAffineTransform,
2598    family: &CFString,
2599) -> Option<CFRetained<CTFont>> {
2600    extern "C-unwind" {
2601        fn CTFontCreateCopyWithFamily(
2602            font: &CTFont,
2603            size: CGFloat,
2604            matrix: *const CGAffineTransform,
2605            family: &CFString,
2606        ) -> Option<NonNull<CTFont>>;
2607    }
2608    let ret = unsafe { CTFontCreateCopyWithFamily(font, size, matrix, family) };
2609    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2610}
2611
2612#[deprecated = "renamed to `CTFont::for_string`"]
2613#[inline]
2614pub unsafe extern "C-unwind" fn CTFontCreateForString(
2615    current_font: &CTFont,
2616    string: &CFString,
2617    range: CFRange,
2618) -> CFRetained<CTFont> {
2619    extern "C-unwind" {
2620        fn CTFontCreateForString(
2621            current_font: &CTFont,
2622            string: &CFString,
2623            range: CFRange,
2624        ) -> Option<NonNull<CTFont>>;
2625    }
2626    let ret = unsafe { CTFontCreateForString(current_font, string, range) };
2627    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2628    unsafe { CFRetained::from_raw(ret) }
2629}
2630
2631#[deprecated = "renamed to `CTFont::for_string_with_language`"]
2632#[inline]
2633pub unsafe extern "C-unwind" fn CTFontCreateForStringWithLanguage(
2634    current_font: &CTFont,
2635    string: &CFString,
2636    range: CFRange,
2637    language: Option<&CFString>,
2638) -> CFRetained<CTFont> {
2639    extern "C-unwind" {
2640        fn CTFontCreateForStringWithLanguage(
2641            current_font: &CTFont,
2642            string: &CFString,
2643            range: CFRange,
2644            language: Option<&CFString>,
2645        ) -> Option<NonNull<CTFont>>;
2646    }
2647    let ret = unsafe { CTFontCreateForStringWithLanguage(current_font, string, range, language) };
2648    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2649    unsafe { CFRetained::from_raw(ret) }
2650}
2651
2652#[cfg(feature = "CTFontDescriptor")]
2653#[deprecated = "renamed to `CTFont::font_descriptor`"]
2654#[inline]
2655pub unsafe extern "C-unwind" fn CTFontCopyFontDescriptor(
2656    font: &CTFont,
2657) -> CFRetained<CTFontDescriptor> {
2658    extern "C-unwind" {
2659        fn CTFontCopyFontDescriptor(font: &CTFont) -> Option<NonNull<CTFontDescriptor>>;
2660    }
2661    let ret = unsafe { CTFontCopyFontDescriptor(font) };
2662    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2663    unsafe { CFRetained::from_raw(ret) }
2664}
2665
2666#[deprecated = "renamed to `CTFont::attribute`"]
2667#[inline]
2668pub unsafe extern "C-unwind" fn CTFontCopyAttribute(
2669    font: &CTFont,
2670    attribute: &CFString,
2671) -> Option<CFRetained<CFType>> {
2672    extern "C-unwind" {
2673        fn CTFontCopyAttribute(font: &CTFont, attribute: &CFString) -> Option<NonNull<CFType>>;
2674    }
2675    let ret = unsafe { CTFontCopyAttribute(font, attribute) };
2676    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2677}
2678
2679extern "C-unwind" {
2680    #[deprecated = "renamed to `CTFont::size`"]
2681    pub fn CTFontGetSize(font: &CTFont) -> CGFloat;
2682}
2683
2684extern "C-unwind" {
2685    #[deprecated = "renamed to `CTFont::matrix`"]
2686    pub fn CTFontGetMatrix(font: &CTFont) -> CGAffineTransform;
2687}
2688
2689extern "C-unwind" {
2690    #[cfg(feature = "CTFontTraits")]
2691    #[deprecated = "renamed to `CTFont::symbolic_traits`"]
2692    pub fn CTFontGetSymbolicTraits(font: &CTFont) -> CTFontSymbolicTraits;
2693}
2694
2695#[deprecated = "renamed to `CTFont::traits`"]
2696#[inline]
2697pub unsafe extern "C-unwind" fn CTFontCopyTraits(font: &CTFont) -> CFRetained<CFDictionary> {
2698    extern "C-unwind" {
2699        fn CTFontCopyTraits(font: &CTFont) -> Option<NonNull<CFDictionary>>;
2700    }
2701    let ret = unsafe { CTFontCopyTraits(font) };
2702    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2703    unsafe { CFRetained::from_raw(ret) }
2704}
2705
2706#[deprecated = "renamed to `CTFont::default_cascade_list_for_languages`"]
2707#[inline]
2708pub unsafe extern "C-unwind" fn CTFontCopyDefaultCascadeListForLanguages(
2709    font: &CTFont,
2710    language_pref_list: Option<&CFArray>,
2711) -> Option<CFRetained<CFArray>> {
2712    extern "C-unwind" {
2713        fn CTFontCopyDefaultCascadeListForLanguages(
2714            font: &CTFont,
2715            language_pref_list: Option<&CFArray>,
2716        ) -> Option<NonNull<CFArray>>;
2717    }
2718    let ret = unsafe { CTFontCopyDefaultCascadeListForLanguages(font, language_pref_list) };
2719    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2720}
2721
2722#[deprecated = "renamed to `CTFont::post_script_name`"]
2723#[inline]
2724pub unsafe extern "C-unwind" fn CTFontCopyPostScriptName(font: &CTFont) -> CFRetained<CFString> {
2725    extern "C-unwind" {
2726        fn CTFontCopyPostScriptName(font: &CTFont) -> Option<NonNull<CFString>>;
2727    }
2728    let ret = unsafe { CTFontCopyPostScriptName(font) };
2729    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2730    unsafe { CFRetained::from_raw(ret) }
2731}
2732
2733#[deprecated = "renamed to `CTFont::family_name`"]
2734#[inline]
2735pub unsafe extern "C-unwind" fn CTFontCopyFamilyName(font: &CTFont) -> CFRetained<CFString> {
2736    extern "C-unwind" {
2737        fn CTFontCopyFamilyName(font: &CTFont) -> Option<NonNull<CFString>>;
2738    }
2739    let ret = unsafe { CTFontCopyFamilyName(font) };
2740    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2741    unsafe { CFRetained::from_raw(ret) }
2742}
2743
2744#[deprecated = "renamed to `CTFont::full_name`"]
2745#[inline]
2746pub unsafe extern "C-unwind" fn CTFontCopyFullName(font: &CTFont) -> CFRetained<CFString> {
2747    extern "C-unwind" {
2748        fn CTFontCopyFullName(font: &CTFont) -> Option<NonNull<CFString>>;
2749    }
2750    let ret = unsafe { CTFontCopyFullName(font) };
2751    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2752    unsafe { CFRetained::from_raw(ret) }
2753}
2754
2755#[deprecated = "renamed to `CTFont::display_name`"]
2756#[inline]
2757pub unsafe extern "C-unwind" fn CTFontCopyDisplayName(font: &CTFont) -> CFRetained<CFString> {
2758    extern "C-unwind" {
2759        fn CTFontCopyDisplayName(font: &CTFont) -> Option<NonNull<CFString>>;
2760    }
2761    let ret = unsafe { CTFontCopyDisplayName(font) };
2762    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2763    unsafe { CFRetained::from_raw(ret) }
2764}
2765
2766#[deprecated = "renamed to `CTFont::name`"]
2767#[inline]
2768pub unsafe extern "C-unwind" fn CTFontCopyName(
2769    font: &CTFont,
2770    name_key: &CFString,
2771) -> Option<CFRetained<CFString>> {
2772    extern "C-unwind" {
2773        fn CTFontCopyName(font: &CTFont, name_key: &CFString) -> Option<NonNull<CFString>>;
2774    }
2775    let ret = unsafe { CTFontCopyName(font, name_key) };
2776    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2777}
2778
2779#[deprecated = "renamed to `CTFont::localized_name`"]
2780#[inline]
2781pub unsafe extern "C-unwind" fn CTFontCopyLocalizedName(
2782    font: &CTFont,
2783    name_key: &CFString,
2784    actual_language: *mut *const CFString,
2785) -> Option<CFRetained<CFString>> {
2786    extern "C-unwind" {
2787        fn CTFontCopyLocalizedName(
2788            font: &CTFont,
2789            name_key: &CFString,
2790            actual_language: *mut *const CFString,
2791        ) -> Option<NonNull<CFString>>;
2792    }
2793    let ret = unsafe { CTFontCopyLocalizedName(font, name_key, actual_language) };
2794    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2795}
2796
2797#[deprecated = "renamed to `CTFont::character_set`"]
2798#[inline]
2799pub unsafe extern "C-unwind" fn CTFontCopyCharacterSet(
2800    font: &CTFont,
2801) -> CFRetained<CFCharacterSet> {
2802    extern "C-unwind" {
2803        fn CTFontCopyCharacterSet(font: &CTFont) -> Option<NonNull<CFCharacterSet>>;
2804    }
2805    let ret = unsafe { CTFontCopyCharacterSet(font) };
2806    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2807    unsafe { CFRetained::from_raw(ret) }
2808}
2809
2810extern "C-unwind" {
2811    #[deprecated = "renamed to `CTFont::string_encoding`"]
2812    pub fn CTFontGetStringEncoding(font: &CTFont) -> CFStringEncoding;
2813}
2814
2815#[deprecated = "renamed to `CTFont::supported_languages`"]
2816#[inline]
2817pub unsafe extern "C-unwind" fn CTFontCopySupportedLanguages(font: &CTFont) -> CFRetained<CFArray> {
2818    extern "C-unwind" {
2819        fn CTFontCopySupportedLanguages(font: &CTFont) -> Option<NonNull<CFArray>>;
2820    }
2821    let ret = unsafe { CTFontCopySupportedLanguages(font) };
2822    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
2823    unsafe { CFRetained::from_raw(ret) }
2824}
2825
2826extern "C-unwind" {
2827    #[cfg(feature = "objc2-core-graphics")]
2828    #[deprecated = "renamed to `CTFont::glyphs_for_characters`"]
2829    pub fn CTFontGetGlyphsForCharacters(
2830        font: &CTFont,
2831        characters: NonNull<UniChar>,
2832        glyphs: NonNull<CGGlyph>,
2833        count: CFIndex,
2834    ) -> bool;
2835}
2836
2837extern "C-unwind" {
2838    #[deprecated = "renamed to `CTFont::ascent`"]
2839    pub fn CTFontGetAscent(font: &CTFont) -> CGFloat;
2840}
2841
2842extern "C-unwind" {
2843    #[deprecated = "renamed to `CTFont::descent`"]
2844    pub fn CTFontGetDescent(font: &CTFont) -> CGFloat;
2845}
2846
2847extern "C-unwind" {
2848    #[deprecated = "renamed to `CTFont::leading`"]
2849    pub fn CTFontGetLeading(font: &CTFont) -> CGFloat;
2850}
2851
2852extern "C-unwind" {
2853    #[deprecated = "renamed to `CTFont::units_per_em`"]
2854    pub fn CTFontGetUnitsPerEm(font: &CTFont) -> c_uint;
2855}
2856
2857extern "C-unwind" {
2858    #[deprecated = "renamed to `CTFont::glyph_count`"]
2859    pub fn CTFontGetGlyphCount(font: &CTFont) -> CFIndex;
2860}
2861
2862extern "C-unwind" {
2863    #[deprecated = "renamed to `CTFont::bounding_box`"]
2864    pub fn CTFontGetBoundingBox(font: &CTFont) -> CGRect;
2865}
2866
2867extern "C-unwind" {
2868    #[deprecated = "renamed to `CTFont::underline_position`"]
2869    pub fn CTFontGetUnderlinePosition(font: &CTFont) -> CGFloat;
2870}
2871
2872extern "C-unwind" {
2873    #[deprecated = "renamed to `CTFont::underline_thickness`"]
2874    pub fn CTFontGetUnderlineThickness(font: &CTFont) -> CGFloat;
2875}
2876
2877extern "C-unwind" {
2878    #[deprecated = "renamed to `CTFont::slant_angle`"]
2879    pub fn CTFontGetSlantAngle(font: &CTFont) -> CGFloat;
2880}
2881
2882extern "C-unwind" {
2883    #[deprecated = "renamed to `CTFont::cap_height`"]
2884    pub fn CTFontGetCapHeight(font: &CTFont) -> CGFloat;
2885}
2886
2887extern "C-unwind" {
2888    #[deprecated = "renamed to `CTFont::x_height`"]
2889    pub fn CTFontGetXHeight(font: &CTFont) -> CGFloat;
2890}
2891
2892extern "C-unwind" {
2893    #[cfg(feature = "objc2-core-graphics")]
2894    #[deprecated = "renamed to `CTFont::glyph_with_name`"]
2895    pub fn CTFontGetGlyphWithName(font: &CTFont, glyph_name: &CFString) -> CGGlyph;
2896}
2897
2898#[cfg(feature = "objc2-core-graphics")]
2899#[deprecated = "renamed to `CTFont::name_for_glyph`"]
2900#[inline]
2901pub unsafe extern "C-unwind" fn CTFontCopyNameForGlyph(
2902    font: &CTFont,
2903    glyph: CGGlyph,
2904) -> Option<CFRetained<CFString>> {
2905    extern "C-unwind" {
2906        fn CTFontCopyNameForGlyph(font: &CTFont, glyph: CGGlyph) -> Option<NonNull<CFString>>;
2907    }
2908    let ret = unsafe { CTFontCopyNameForGlyph(font, glyph) };
2909    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2910}
2911
2912extern "C-unwind" {
2913    #[cfg(all(feature = "CTFontDescriptor", feature = "objc2-core-graphics"))]
2914    #[deprecated = "renamed to `CTFont::bounding_rects_for_glyphs`"]
2915    pub fn CTFontGetBoundingRectsForGlyphs(
2916        font: &CTFont,
2917        orientation: CTFontOrientation,
2918        glyphs: NonNull<CGGlyph>,
2919        bounding_rects: *mut CGRect,
2920        count: CFIndex,
2921    ) -> CGRect;
2922}
2923
2924extern "C-unwind" {
2925    #[cfg(feature = "objc2-core-graphics")]
2926    #[deprecated = "renamed to `CTFont::optical_bounds_for_glyphs`"]
2927    pub fn CTFontGetOpticalBoundsForGlyphs(
2928        font: &CTFont,
2929        glyphs: NonNull<CGGlyph>,
2930        bounding_rects: *mut CGRect,
2931        count: CFIndex,
2932        options: CFOptionFlags,
2933    ) -> CGRect;
2934}
2935
2936extern "C-unwind" {
2937    #[cfg(all(feature = "CTFontDescriptor", feature = "objc2-core-graphics"))]
2938    #[deprecated = "renamed to `CTFont::advances_for_glyphs`"]
2939    pub fn CTFontGetAdvancesForGlyphs(
2940        font: &CTFont,
2941        orientation: CTFontOrientation,
2942        glyphs: NonNull<CGGlyph>,
2943        advances: *mut CGSize,
2944        count: CFIndex,
2945    ) -> c_double;
2946}
2947
2948extern "C-unwind" {
2949    #[cfg(feature = "objc2-core-graphics")]
2950    #[deprecated = "renamed to `CTFont::vertical_translations_for_glyphs`"]
2951    pub fn CTFontGetVerticalTranslationsForGlyphs(
2952        font: &CTFont,
2953        glyphs: NonNull<CGGlyph>,
2954        translations: NonNull<CGSize>,
2955        count: CFIndex,
2956    );
2957}
2958
2959#[cfg(feature = "objc2-core-graphics")]
2960#[deprecated = "renamed to `CTFont::path_for_glyph`"]
2961#[inline]
2962pub unsafe extern "C-unwind" fn CTFontCreatePathForGlyph(
2963    font: &CTFont,
2964    glyph: CGGlyph,
2965    matrix: *const CGAffineTransform,
2966) -> Option<CFRetained<CGPath>> {
2967    extern "C-unwind" {
2968        fn CTFontCreatePathForGlyph(
2969            font: &CTFont,
2970            glyph: CGGlyph,
2971            matrix: *const CGAffineTransform,
2972        ) -> Option<NonNull<CGPath>>;
2973    }
2974    let ret = unsafe { CTFontCreatePathForGlyph(font, glyph, matrix) };
2975    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2976}
2977
2978#[deprecated = "renamed to `CTFont::variation_axes`"]
2979#[inline]
2980pub unsafe extern "C-unwind" fn CTFontCopyVariationAxes(
2981    font: &CTFont,
2982) -> Option<CFRetained<CFArray>> {
2983    extern "C-unwind" {
2984        fn CTFontCopyVariationAxes(font: &CTFont) -> Option<NonNull<CFArray>>;
2985    }
2986    let ret = unsafe { CTFontCopyVariationAxes(font) };
2987    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2988}
2989
2990#[deprecated = "renamed to `CTFont::variation`"]
2991#[inline]
2992pub unsafe extern "C-unwind" fn CTFontCopyVariation(
2993    font: &CTFont,
2994) -> Option<CFRetained<CFDictionary>> {
2995    extern "C-unwind" {
2996        fn CTFontCopyVariation(font: &CTFont) -> Option<NonNull<CFDictionary>>;
2997    }
2998    let ret = unsafe { CTFontCopyVariation(font) };
2999    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
3000}
3001
3002#[deprecated = "renamed to `CTFont::features`"]
3003#[inline]
3004pub unsafe extern "C-unwind" fn CTFontCopyFeatures(font: &CTFont) -> Option<CFRetained<CFArray>> {
3005    extern "C-unwind" {
3006        fn CTFontCopyFeatures(font: &CTFont) -> Option<NonNull<CFArray>>;
3007    }
3008    let ret = unsafe { CTFontCopyFeatures(font) };
3009    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
3010}
3011
3012#[deprecated = "renamed to `CTFont::feature_settings`"]
3013#[inline]
3014pub unsafe extern "C-unwind" fn CTFontCopyFeatureSettings(
3015    font: &CTFont,
3016) -> Option<CFRetained<CFArray>> {
3017    extern "C-unwind" {
3018        fn CTFontCopyFeatureSettings(font: &CTFont) -> Option<NonNull<CFArray>>;
3019    }
3020    let ret = unsafe { CTFontCopyFeatureSettings(font) };
3021    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
3022}
3023
3024#[cfg(all(feature = "CTFontDescriptor", feature = "objc2-core-graphics"))]
3025#[deprecated = "renamed to `CTFont::graphics_font`"]
3026#[inline]
3027pub unsafe extern "C-unwind" fn CTFontCopyGraphicsFont(
3028    font: &CTFont,
3029    attributes: *mut *const CTFontDescriptor,
3030) -> CFRetained<CGFont> {
3031    extern "C-unwind" {
3032        fn CTFontCopyGraphicsFont(
3033            font: &CTFont,
3034            attributes: *mut *const CTFontDescriptor,
3035        ) -> Option<NonNull<CGFont>>;
3036    }
3037    let ret = unsafe { CTFontCopyGraphicsFont(font, attributes) };
3038    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
3039    unsafe { CFRetained::from_raw(ret) }
3040}
3041
3042#[cfg(all(feature = "CTFontDescriptor", feature = "objc2-core-graphics"))]
3043#[deprecated = "renamed to `CTFont::with_graphics_font`"]
3044#[inline]
3045pub unsafe extern "C-unwind" fn CTFontCreateWithGraphicsFont(
3046    graphics_font: &CGFont,
3047    size: CGFloat,
3048    matrix: *const CGAffineTransform,
3049    attributes: Option<&CTFontDescriptor>,
3050) -> CFRetained<CTFont> {
3051    extern "C-unwind" {
3052        fn CTFontCreateWithGraphicsFont(
3053            graphics_font: &CGFont,
3054            size: CGFloat,
3055            matrix: *const CGAffineTransform,
3056            attributes: Option<&CTFontDescriptor>,
3057        ) -> Option<NonNull<CTFont>>;
3058    }
3059    let ret = unsafe { CTFontCreateWithGraphicsFont(graphics_font, size, matrix, attributes) };
3060    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
3061    unsafe { CFRetained::from_raw(ret) }
3062}
3063
3064#[deprecated = "renamed to `CTFont::with_quickdraw_instance`"]
3065#[inline]
3066pub unsafe extern "C-unwind" fn CTFontCreateWithQuickdrawInstance(
3067    name: ConstStr255Param,
3068    identifier: i16,
3069    style: u8,
3070    size: CGFloat,
3071) -> CFRetained<CTFont> {
3072    extern "C-unwind" {
3073        fn CTFontCreateWithQuickdrawInstance(
3074            name: ConstStr255Param,
3075            identifier: i16,
3076            style: u8,
3077            size: CGFloat,
3078        ) -> Option<NonNull<CTFont>>;
3079    }
3080    let ret = unsafe { CTFontCreateWithQuickdrawInstance(name, identifier, style, size) };
3081    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
3082    unsafe { CFRetained::from_raw(ret) }
3083}
3084
3085#[deprecated = "renamed to `CTFont::available_tables`"]
3086#[inline]
3087pub unsafe extern "C-unwind" fn CTFontCopyAvailableTables(
3088    font: &CTFont,
3089    options: CTFontTableOptions,
3090) -> Option<CFRetained<CFArray>> {
3091    extern "C-unwind" {
3092        fn CTFontCopyAvailableTables(
3093            font: &CTFont,
3094            options: CTFontTableOptions,
3095        ) -> Option<NonNull<CFArray>>;
3096    }
3097    let ret = unsafe { CTFontCopyAvailableTables(font, options) };
3098    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
3099}
3100
3101extern "C-unwind" {
3102    #[deprecated = "renamed to `CTFont::has_table`"]
3103    pub fn CTFontHasTable(font: &CTFont, tag: CTFontTableTag) -> bool;
3104}
3105
3106#[deprecated = "renamed to `CTFont::table`"]
3107#[inline]
3108pub unsafe extern "C-unwind" fn CTFontCopyTable(
3109    font: &CTFont,
3110    table: CTFontTableTag,
3111    options: CTFontTableOptions,
3112) -> Option<CFRetained<CFData>> {
3113    extern "C-unwind" {
3114        fn CTFontCopyTable(
3115            font: &CTFont,
3116            table: CTFontTableTag,
3117            options: CTFontTableOptions,
3118        ) -> Option<NonNull<CFData>>;
3119    }
3120    let ret = unsafe { CTFontCopyTable(font, table, options) };
3121    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
3122}
3123
3124extern "C-unwind" {
3125    #[cfg(feature = "objc2-core-graphics")]
3126    #[deprecated = "renamed to `CTFont::draw_glyphs`"]
3127    pub fn CTFontDrawGlyphs(
3128        font: &CTFont,
3129        glyphs: NonNull<CGGlyph>,
3130        positions: NonNull<CGPoint>,
3131        count: usize,
3132        context: &CGContext,
3133    );
3134}
3135
3136extern "C-unwind" {
3137    #[cfg(feature = "objc2-core-graphics")]
3138    #[deprecated = "renamed to `CTFont::ligature_caret_positions`"]
3139    pub fn CTFontGetLigatureCaretPositions(
3140        font: &CTFont,
3141        glyph: CGGlyph,
3142        positions: *mut CGFloat,
3143        max_positions: CFIndex,
3144    ) -> CFIndex;
3145}
3146
3147extern "C-unwind" {
3148    #[cfg(all(feature = "CTRunDelegate", feature = "objc2"))]
3149    #[deprecated = "renamed to `CTFont::typographic_bounds_for_adaptive_image_provider`"]
3150    pub fn CTFontGetTypographicBoundsForAdaptiveImageProvider(
3151        font: &CTFont,
3152        provider: Option<&ProtocolObject<dyn CTAdaptiveImageProviding>>,
3153    ) -> CGRect;
3154}
3155
3156extern "C-unwind" {
3157    #[cfg(all(
3158        feature = "CTRunDelegate",
3159        feature = "objc2",
3160        feature = "objc2-core-graphics"
3161    ))]
3162    #[deprecated = "renamed to `CTFont::draw_image_from_adaptive_image_provider_at_point`"]
3163    pub fn CTFontDrawImageFromAdaptiveImageProviderAtPoint(
3164        font: &CTFont,
3165        provider: &ProtocolObject<dyn CTAdaptiveImageProviding>,
3166        point: CGPoint,
3167        context: &CGContext,
3168    );
3169}