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