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