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    #[encoding_name = "__CTGlyphInfo"]
23    unsafe impl CTGlyphInfo {}
24);
25
26unsafe impl ConcreteType for CTGlyphInfo {
27    /// Returns the CFType of the glyph info object
28    #[doc(alias = "CTGlyphInfoGetTypeID")]
29    #[inline]
30    fn type_id() -> CFTypeID {
31        extern "C-unwind" {
32            fn CTGlyphInfoGetTypeID() -> CFTypeID;
33        }
34        unsafe { CTGlyphInfoGetTypeID() }
35    }
36}
37
38/// These constants specify character collections.
39///
40///
41/// Indicates that the character identifier is equal to the CGGlyph
42/// glyph index.
43///
44///
45/// Indicates the Adobe-CNS1 mapping.
46///
47///
48/// Indicates the Adobe-GB1 mapping.
49///
50///
51/// Indicates the Adobe-Japan1 mapping.
52///
53///
54/// Indicates the Adobe-Japan2 mapping.
55///
56///
57/// Indicates the Adobe-Korea1 mapping.
58///
59/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctcharactercollection?language=objc)
60// NS_ENUM
61#[repr(transparent)]
62#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
63pub struct CTCharacterCollection(pub u16);
64impl CTCharacterCollection {
65    #[doc(alias = "kCTCharacterCollectionIdentityMapping")]
66    pub const IdentityMapping: Self = Self(0);
67    #[doc(alias = "kCTCharacterCollectionAdobeCNS1")]
68    pub const AdobeCNS1: Self = Self(1);
69    #[doc(alias = "kCTCharacterCollectionAdobeGB1")]
70    pub const AdobeGB1: Self = Self(2);
71    #[doc(alias = "kCTCharacterCollectionAdobeJapan1")]
72    pub const AdobeJapan1: Self = Self(3);
73    #[doc(alias = "kCTCharacterCollectionAdobeJapan2")]
74    pub const AdobeJapan2: Self = Self(4);
75    #[doc(alias = "kCTCharacterCollectionAdobeKorea1")]
76    pub const AdobeKorea1: Self = Self(5);
77    #[deprecated = "Deprecated"]
78    pub const kCTIdentityMappingCharacterCollection: Self =
79        Self(CTCharacterCollection::IdentityMapping.0);
80    #[deprecated = "Deprecated"]
81    pub const kCTAdobeCNS1CharacterCollection: Self = Self(CTCharacterCollection::AdobeCNS1.0);
82    #[deprecated = "Deprecated"]
83    pub const kCTAdobeGB1CharacterCollection: Self = Self(CTCharacterCollection::AdobeGB1.0);
84    #[deprecated = "Deprecated"]
85    pub const kCTAdobeJapan1CharacterCollection: Self = Self(CTCharacterCollection::AdobeJapan1.0);
86    #[deprecated = "Deprecated"]
87    pub const kCTAdobeJapan2CharacterCollection: Self = Self(CTCharacterCollection::AdobeJapan2.0);
88    #[deprecated = "Deprecated"]
89    pub const kCTAdobeKorea1CharacterCollection: Self = Self(CTCharacterCollection::AdobeKorea1.0);
90}
91
92#[cfg(feature = "objc2")]
93unsafe impl Encode for CTCharacterCollection {
94    const ENCODING: Encoding = u16::ENCODING;
95}
96
97#[cfg(feature = "objc2")]
98unsafe impl RefEncode for CTCharacterCollection {
99    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
100}
101
102/// Creates an immutable glyph info object.
103///
104///
105/// This function creates an immutable glyph info object for a glyph
106/// name such as "copyright" and a specified font.
107///
108///
109/// Parameter `glyphName`: The name of the glyph.
110///
111///
112/// Parameter `font`: The font to be associated with the returned CTGlyphInfo object.
113///
114///
115/// Parameter `baseString`: The part of the string the returned object is intended
116/// to override.
117///
118///
119/// Returns: This function will return a reference to a CTGlyphInfo object.
120#[cfg(feature = "CTFont")]
121#[inline]
122pub unsafe extern "C-unwind" fn CTGlyphInfoCreateWithGlyphName(
123    glyph_name: &CFString,
124    font: &CTFont,
125    base_string: &CFString,
126) -> Option<CFRetained<CTGlyphInfo>> {
127    extern "C-unwind" {
128        fn CTGlyphInfoCreateWithGlyphName(
129            glyph_name: &CFString,
130            font: &CTFont,
131            base_string: &CFString,
132        ) -> Option<NonNull<CTGlyphInfo>>;
133    }
134    let ret = unsafe { CTGlyphInfoCreateWithGlyphName(glyph_name, font, base_string) };
135    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
136}
137
138/// Creates an immutable glyph info object.
139///
140///
141/// This function creates an immutable glyph info object for a glyph
142/// index and a specified font.
143///
144///
145/// Parameter `glyph`: The glyph identifier.
146///
147///
148/// Parameter `font`: The font to be associated with the returned CTGlyphInfo object.
149///
150///
151/// Parameter `baseString`: The part of the string the returned object is intended
152/// to override.
153///
154///
155/// Returns: This function will return a reference to a CTGlyphInfo object.
156#[cfg(all(feature = "CTFont", feature = "objc2-core-graphics"))]
157#[inline]
158pub unsafe extern "C-unwind" fn CTGlyphInfoCreateWithGlyph(
159    glyph: CGGlyph,
160    font: &CTFont,
161    base_string: &CFString,
162) -> Option<CFRetained<CTGlyphInfo>> {
163    extern "C-unwind" {
164        fn CTGlyphInfoCreateWithGlyph(
165            glyph: CGGlyph,
166            font: &CTFont,
167            base_string: &CFString,
168        ) -> Option<NonNull<CTGlyphInfo>>;
169    }
170    let ret = unsafe { CTGlyphInfoCreateWithGlyph(glyph, font, base_string) };
171    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
172}
173
174/// Creates an immutable glyph info object.
175///
176///
177/// This function creates an immutable glyph info object for a
178/// character identifier and a character collection.
179///
180///
181/// Parameter `cid`: A character identifier.
182///
183///
184/// Parameter `collection`: A character collection identifier.
185///
186///
187/// Parameter `baseString`: The part of the string the returned object is intended
188/// to override.
189///
190///
191/// Returns: This function will return a reference to a CTGlyphInfo object.
192#[cfg(feature = "objc2-core-graphics")]
193#[inline]
194pub unsafe extern "C-unwind" fn CTGlyphInfoCreateWithCharacterIdentifier(
195    cid: CGFontIndex,
196    collection: CTCharacterCollection,
197    base_string: &CFString,
198) -> Option<CFRetained<CTGlyphInfo>> {
199    extern "C-unwind" {
200        fn CTGlyphInfoCreateWithCharacterIdentifier(
201            cid: CGFontIndex,
202            collection: CTCharacterCollection,
203            base_string: &CFString,
204        ) -> Option<NonNull<CTGlyphInfo>>;
205    }
206    let ret = unsafe { CTGlyphInfoCreateWithCharacterIdentifier(cid, collection, base_string) };
207    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
208}
209
210/// Gets the glyph name for a glyph info, if applicable.
211///
212///
213/// This function will return the glyph name.
214///
215///
216/// Parameter `glyphInfo`: The glyph info for which you would like the glyph name.
217///
218///
219/// Returns: If the glyph info object was created with a glyph name, it will
220/// be returned. Otherwise, this function will return NULL.
221#[inline]
222pub unsafe extern "C-unwind" fn CTGlyphInfoGetGlyphName(
223    glyph_info: &CTGlyphInfo,
224) -> Option<CFRetained<CFString>> {
225    extern "C-unwind" {
226        fn CTGlyphInfoGetGlyphName(glyph_info: &CTGlyphInfo) -> Option<NonNull<CFString>>;
227    }
228    let ret = unsafe { CTGlyphInfoGetGlyphName(glyph_info) };
229    ret.map(|ret| unsafe { CFRetained::retain(ret) })
230}
231
232extern "C-unwind" {
233    /// Gets the glyph for a glyph info, if applicable.
234    ///
235    ///
236    /// This function will return the glyph.
237    ///
238    ///
239    /// Parameter `glyphInfo`: The glyph info from which you would like the glyph.
240    ///
241    ///
242    /// Returns: If the glyph info object was created with a font, it will be
243    /// returned. Otherwise, this function will return 0.
244    #[cfg(feature = "objc2-core-graphics")]
245    pub fn CTGlyphInfoGetGlyph(glyph_info: &CTGlyphInfo) -> CGGlyph;
246}
247
248extern "C-unwind" {
249    /// Gets the character identifier for a glyph info.
250    ///
251    ///
252    /// This function will return the character identifier.
253    ///
254    ///
255    /// Parameter `glyphInfo`: The glyph info for which you would like the character identifier.
256    ///
257    ///
258    /// Returns: If the glyph info object was created with a character identifier,
259    /// it will be returned. Otherwise, this function will return 0.
260    #[cfg(feature = "objc2-core-graphics")]
261    pub fn CTGlyphInfoGetCharacterIdentifier(glyph_info: &CTGlyphInfo) -> CGFontIndex;
262}
263
264extern "C-unwind" {
265    /// Gets the character collection for a glyph info.
266    ///
267    ///
268    /// This function will return the character collection. If the glyph
269    /// info object was created with a glyph name or a glyph index, its
270    /// character collection will be
271    /// kCTIdentityMappingCharacterCollection.
272    ///
273    ///
274    /// Parameter `glyphInfo`: The glyph info for which you would like the character collection.
275    ///
276    ///
277    /// Returns: This function will return the character collection of the given
278    /// glyph info.
279    pub fn CTGlyphInfoGetCharacterCollection(glyph_info: &CTGlyphInfo) -> CTCharacterCollection;
280}