objc2_core_text/generated/
CTGlyphInfo.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::marker::{PhantomData, PhantomPinned};
5use core::ptr::NonNull;
6#[cfg(feature = "objc2")]
7use objc2::__framework_prelude::*;
8use objc2_core_foundation::*;
9#[cfg(feature = "objc2-core-graphics")]
10use objc2_core_graphics::*;
11
12use crate::*;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctglyphinfo?language=objc)
15///
16/// This is toll-free bridged with `NSGlyphInfo`.
17#[doc(alias = "CTGlyphInfoRef")]
18#[repr(C)]
19pub struct CTGlyphInfo {
20    inner: [u8; 0],
21    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
22}
23
24cf_type!(
25    unsafe impl CTGlyphInfo {}
26);
27#[cfg(feature = "objc2")]
28cf_objc2_type!(
29    unsafe impl RefEncode<"__CTGlyphInfo"> for CTGlyphInfo {}
30);
31
32unsafe impl ConcreteType for CTGlyphInfo {
33    /// Returns the CFType of the glyph info object
34    #[doc(alias = "CTGlyphInfoGetTypeID")]
35    #[inline]
36    fn type_id() -> CFTypeID {
37        extern "C-unwind" {
38            fn CTGlyphInfoGetTypeID() -> CFTypeID;
39        }
40        unsafe { CTGlyphInfoGetTypeID() }
41    }
42}
43
44/// These constants specify character collections.
45///
46///
47/// Indicates that the character identifier is equal to the CGGlyph
48/// glyph index.
49///
50///
51/// Indicates the Adobe-CNS1 mapping.
52///
53///
54/// Indicates the Adobe-GB1 mapping.
55///
56///
57/// Indicates the Adobe-Japan1 mapping.
58///
59///
60/// Indicates the Adobe-Japan2 mapping.
61///
62///
63/// Indicates the Adobe-Korea1 mapping.
64///
65/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctcharactercollection?language=objc)
66// NS_ENUM
67#[repr(transparent)]
68#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
69pub struct CTCharacterCollection(pub u16);
70impl CTCharacterCollection {
71    #[doc(alias = "kCTCharacterCollectionIdentityMapping")]
72    pub const IdentityMapping: Self = Self(0);
73    #[doc(alias = "kCTCharacterCollectionAdobeCNS1")]
74    pub const AdobeCNS1: Self = Self(1);
75    #[doc(alias = "kCTCharacterCollectionAdobeGB1")]
76    pub const AdobeGB1: Self = Self(2);
77    #[doc(alias = "kCTCharacterCollectionAdobeJapan1")]
78    pub const AdobeJapan1: Self = Self(3);
79    #[doc(alias = "kCTCharacterCollectionAdobeJapan2")]
80    pub const AdobeJapan2: Self = Self(4);
81    #[doc(alias = "kCTCharacterCollectionAdobeKorea1")]
82    pub const AdobeKorea1: Self = Self(5);
83    #[deprecated = "Deprecated"]
84    pub const kCTIdentityMappingCharacterCollection: Self =
85        Self(CTCharacterCollection::IdentityMapping.0);
86    #[deprecated = "Deprecated"]
87    pub const kCTAdobeCNS1CharacterCollection: Self = Self(CTCharacterCollection::AdobeCNS1.0);
88    #[deprecated = "Deprecated"]
89    pub const kCTAdobeGB1CharacterCollection: Self = Self(CTCharacterCollection::AdobeGB1.0);
90    #[deprecated = "Deprecated"]
91    pub const kCTAdobeJapan1CharacterCollection: Self = Self(CTCharacterCollection::AdobeJapan1.0);
92    #[deprecated = "Deprecated"]
93    pub const kCTAdobeJapan2CharacterCollection: Self = Self(CTCharacterCollection::AdobeJapan2.0);
94    #[deprecated = "Deprecated"]
95    pub const kCTAdobeKorea1CharacterCollection: Self = Self(CTCharacterCollection::AdobeKorea1.0);
96}
97
98#[cfg(feature = "objc2")]
99unsafe impl Encode for CTCharacterCollection {
100    const ENCODING: Encoding = u16::ENCODING;
101}
102
103#[cfg(feature = "objc2")]
104unsafe impl RefEncode for CTCharacterCollection {
105    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
106}
107
108impl CTGlyphInfo {
109    /// Creates an immutable glyph info object.
110    ///
111    ///
112    /// This function creates an immutable glyph info object for a glyph
113    /// name such as "copyright" and a specified font.
114    ///
115    ///
116    /// Parameter `glyphName`: The name of the glyph.
117    ///
118    ///
119    /// Parameter `font`: The font to be associated with the returned CTGlyphInfo object.
120    ///
121    ///
122    /// Parameter `baseString`: The part of the string the returned object is intended
123    /// to override.
124    ///
125    ///
126    /// Returns: This function will return a reference to a CTGlyphInfo object.
127    #[doc(alias = "CTGlyphInfoCreateWithGlyphName")]
128    #[cfg(feature = "CTFont")]
129    #[inline]
130    pub unsafe fn with_glyph_name(
131        glyph_name: &CFString,
132        font: &CTFont,
133        base_string: &CFString,
134    ) -> Option<CFRetained<CTGlyphInfo>> {
135        extern "C-unwind" {
136            fn CTGlyphInfoCreateWithGlyphName(
137                glyph_name: &CFString,
138                font: &CTFont,
139                base_string: &CFString,
140            ) -> Option<NonNull<CTGlyphInfo>>;
141        }
142        let ret = unsafe { CTGlyphInfoCreateWithGlyphName(glyph_name, font, base_string) };
143        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
144    }
145
146    /// Creates an immutable glyph info object.
147    ///
148    ///
149    /// This function creates an immutable glyph info object for a glyph
150    /// index and a specified font.
151    ///
152    ///
153    /// Parameter `glyph`: The glyph identifier.
154    ///
155    ///
156    /// Parameter `font`: The font to be associated with the returned CTGlyphInfo object.
157    ///
158    ///
159    /// Parameter `baseString`: The part of the string the returned object is intended
160    /// to override.
161    ///
162    ///
163    /// Returns: This function will return a reference to a CTGlyphInfo object.
164    #[doc(alias = "CTGlyphInfoCreateWithGlyph")]
165    #[cfg(all(feature = "CTFont", feature = "objc2-core-graphics"))]
166    #[inline]
167    pub unsafe fn with_glyph(
168        glyph: CGGlyph,
169        font: &CTFont,
170        base_string: &CFString,
171    ) -> Option<CFRetained<CTGlyphInfo>> {
172        extern "C-unwind" {
173            fn CTGlyphInfoCreateWithGlyph(
174                glyph: CGGlyph,
175                font: &CTFont,
176                base_string: &CFString,
177            ) -> Option<NonNull<CTGlyphInfo>>;
178        }
179        let ret = unsafe { CTGlyphInfoCreateWithGlyph(glyph, font, base_string) };
180        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
181    }
182
183    /// Creates an immutable glyph info object.
184    ///
185    ///
186    /// This function creates an immutable glyph info object for a
187    /// character identifier and a character collection.
188    ///
189    ///
190    /// Parameter `cid`: A character identifier.
191    ///
192    ///
193    /// Parameter `collection`: A character collection identifier.
194    ///
195    ///
196    /// Parameter `baseString`: The part of the string the returned object is intended
197    /// to override.
198    ///
199    ///
200    /// Returns: This function will return a reference to a CTGlyphInfo object.
201    #[doc(alias = "CTGlyphInfoCreateWithCharacterIdentifier")]
202    #[cfg(feature = "objc2-core-graphics")]
203    #[inline]
204    pub unsafe fn with_character_identifier(
205        cid: CGFontIndex,
206        collection: CTCharacterCollection,
207        base_string: &CFString,
208    ) -> Option<CFRetained<CTGlyphInfo>> {
209        extern "C-unwind" {
210            fn CTGlyphInfoCreateWithCharacterIdentifier(
211                cid: CGFontIndex,
212                collection: CTCharacterCollection,
213                base_string: &CFString,
214            ) -> Option<NonNull<CTGlyphInfo>>;
215        }
216        let ret = unsafe { CTGlyphInfoCreateWithCharacterIdentifier(cid, collection, base_string) };
217        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
218    }
219
220    /// Gets the glyph name for a glyph info, if applicable.
221    ///
222    ///
223    /// This function will return the glyph name.
224    ///
225    ///
226    /// Parameter `glyphInfo`: The glyph info for which you would like the glyph name.
227    ///
228    ///
229    /// Returns: If the glyph info object was created with a glyph name, it will
230    /// be returned. Otherwise, this function will return NULL.
231    #[doc(alias = "CTGlyphInfoGetGlyphName")]
232    #[inline]
233    pub unsafe fn glyph_name(&self) -> Option<CFRetained<CFString>> {
234        extern "C-unwind" {
235            fn CTGlyphInfoGetGlyphName(glyph_info: &CTGlyphInfo) -> Option<NonNull<CFString>>;
236        }
237        let ret = unsafe { CTGlyphInfoGetGlyphName(self) };
238        ret.map(|ret| unsafe { CFRetained::retain(ret) })
239    }
240
241    /// Gets the glyph for a glyph info, if applicable.
242    ///
243    ///
244    /// This function will return the glyph.
245    ///
246    ///
247    /// Parameter `glyphInfo`: The glyph info from which you would like the glyph.
248    ///
249    ///
250    /// Returns: If the glyph info object was created with a font, it will be
251    /// returned. Otherwise, this function will return 0.
252    #[doc(alias = "CTGlyphInfoGetGlyph")]
253    #[cfg(feature = "objc2-core-graphics")]
254    #[inline]
255    pub unsafe fn glyph(&self) -> CGGlyph {
256        extern "C-unwind" {
257            fn CTGlyphInfoGetGlyph(glyph_info: &CTGlyphInfo) -> CGGlyph;
258        }
259        unsafe { CTGlyphInfoGetGlyph(self) }
260    }
261
262    /// Gets the character identifier for a glyph info.
263    ///
264    ///
265    /// This function will return the character identifier.
266    ///
267    ///
268    /// Parameter `glyphInfo`: The glyph info for which you would like the character identifier.
269    ///
270    ///
271    /// Returns: If the glyph info object was created with a character identifier,
272    /// it will be returned. Otherwise, this function will return 0.
273    #[doc(alias = "CTGlyphInfoGetCharacterIdentifier")]
274    #[cfg(feature = "objc2-core-graphics")]
275    #[inline]
276    pub unsafe fn character_identifier(&self) -> CGFontIndex {
277        extern "C-unwind" {
278            fn CTGlyphInfoGetCharacterIdentifier(glyph_info: &CTGlyphInfo) -> CGFontIndex;
279        }
280        unsafe { CTGlyphInfoGetCharacterIdentifier(self) }
281    }
282
283    /// Gets the character collection for a glyph info.
284    ///
285    ///
286    /// This function will return the character collection. If the glyph
287    /// info object was created with a glyph name or a glyph index, its
288    /// character collection will be
289    /// kCTIdentityMappingCharacterCollection.
290    ///
291    ///
292    /// Parameter `glyphInfo`: The glyph info for which you would like the character collection.
293    ///
294    ///
295    /// Returns: This function will return the character collection of the given
296    /// glyph info.
297    #[doc(alias = "CTGlyphInfoGetCharacterCollection")]
298    #[inline]
299    pub unsafe fn character_collection(&self) -> CTCharacterCollection {
300        extern "C-unwind" {
301            fn CTGlyphInfoGetCharacterCollection(glyph_info: &CTGlyphInfo)
302                -> CTCharacterCollection;
303        }
304        unsafe { CTGlyphInfoGetCharacterCollection(self) }
305    }
306}
307
308#[cfg(feature = "CTFont")]
309#[deprecated = "renamed to `CTGlyphInfo::with_glyph_name`"]
310#[inline]
311pub unsafe extern "C-unwind" fn CTGlyphInfoCreateWithGlyphName(
312    glyph_name: &CFString,
313    font: &CTFont,
314    base_string: &CFString,
315) -> Option<CFRetained<CTGlyphInfo>> {
316    extern "C-unwind" {
317        fn CTGlyphInfoCreateWithGlyphName(
318            glyph_name: &CFString,
319            font: &CTFont,
320            base_string: &CFString,
321        ) -> Option<NonNull<CTGlyphInfo>>;
322    }
323    let ret = unsafe { CTGlyphInfoCreateWithGlyphName(glyph_name, font, base_string) };
324    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
325}
326
327#[cfg(all(feature = "CTFont", feature = "objc2-core-graphics"))]
328#[deprecated = "renamed to `CTGlyphInfo::with_glyph`"]
329#[inline]
330pub unsafe extern "C-unwind" fn CTGlyphInfoCreateWithGlyph(
331    glyph: CGGlyph,
332    font: &CTFont,
333    base_string: &CFString,
334) -> Option<CFRetained<CTGlyphInfo>> {
335    extern "C-unwind" {
336        fn CTGlyphInfoCreateWithGlyph(
337            glyph: CGGlyph,
338            font: &CTFont,
339            base_string: &CFString,
340        ) -> Option<NonNull<CTGlyphInfo>>;
341    }
342    let ret = unsafe { CTGlyphInfoCreateWithGlyph(glyph, font, base_string) };
343    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
344}
345
346#[cfg(feature = "objc2-core-graphics")]
347#[deprecated = "renamed to `CTGlyphInfo::with_character_identifier`"]
348#[inline]
349pub unsafe extern "C-unwind" fn CTGlyphInfoCreateWithCharacterIdentifier(
350    cid: CGFontIndex,
351    collection: CTCharacterCollection,
352    base_string: &CFString,
353) -> Option<CFRetained<CTGlyphInfo>> {
354    extern "C-unwind" {
355        fn CTGlyphInfoCreateWithCharacterIdentifier(
356            cid: CGFontIndex,
357            collection: CTCharacterCollection,
358            base_string: &CFString,
359        ) -> Option<NonNull<CTGlyphInfo>>;
360    }
361    let ret = unsafe { CTGlyphInfoCreateWithCharacterIdentifier(cid, collection, base_string) };
362    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
363}
364
365#[deprecated = "renamed to `CTGlyphInfo::glyph_name`"]
366#[inline]
367pub unsafe extern "C-unwind" fn CTGlyphInfoGetGlyphName(
368    glyph_info: &CTGlyphInfo,
369) -> Option<CFRetained<CFString>> {
370    extern "C-unwind" {
371        fn CTGlyphInfoGetGlyphName(glyph_info: &CTGlyphInfo) -> Option<NonNull<CFString>>;
372    }
373    let ret = unsafe { CTGlyphInfoGetGlyphName(glyph_info) };
374    ret.map(|ret| unsafe { CFRetained::retain(ret) })
375}
376
377extern "C-unwind" {
378    #[cfg(feature = "objc2-core-graphics")]
379    #[deprecated = "renamed to `CTGlyphInfo::glyph`"]
380    pub fn CTGlyphInfoGetGlyph(glyph_info: &CTGlyphInfo) -> CGGlyph;
381}
382
383extern "C-unwind" {
384    #[cfg(feature = "objc2-core-graphics")]
385    #[deprecated = "renamed to `CTGlyphInfo::character_identifier`"]
386    pub fn CTGlyphInfoGetCharacterIdentifier(glyph_info: &CTGlyphInfo) -> CGFontIndex;
387}
388
389extern "C-unwind" {
390    #[deprecated = "renamed to `CTGlyphInfo::character_collection`"]
391    pub fn CTGlyphInfoGetCharacterCollection(glyph_info: &CTGlyphInfo) -> CTCharacterCollection;
392}