objc2_core_text/generated/
CTFramesetter.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/ctframesetter?language=objc)
15#[repr(C)]
16pub struct CTFramesetter {
17    inner: [u8; 0],
18    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21cf_type!(
22    unsafe impl CTFramesetter {}
23);
24#[cfg(feature = "objc2")]
25cf_objc2_type!(
26    unsafe impl RefEncode<"__CTFramesetter"> for CTFramesetter {}
27);
28
29unsafe impl ConcreteType for CTFramesetter {
30    /// Returns the CFType of the framesetter object
31    #[doc(alias = "CTFramesetterGetTypeID")]
32    #[inline]
33    fn type_id() -> CFTypeID {
34        extern "C-unwind" {
35            fn CTFramesetterGetTypeID() -> CFTypeID;
36        }
37        unsafe { CTFramesetterGetTypeID() }
38    }
39}
40
41impl CTFramesetter {
42    /// Creates a framesetter directly from a typesetter.
43    ///
44    ///
45    /// Each framesetter uses a typesetter internally to perform
46    /// line breaking and other contextual analysis based on the
47    /// characters in a string. This function allows use of a
48    /// typesetter that was constructed using specific options.
49    ///
50    ///
51    /// Parameter `typesetter`: The typesetter to be used by the newly-created framesetter.
52    ///
53    ///
54    /// Returns: This function will return a reference to a CTFramesetter object.
55    ///
56    ///
57    /// See also: CTTypesetterCreateWithAttributedStringAndOptions
58    #[doc(alias = "CTFramesetterCreateWithTypesetter")]
59    #[cfg(feature = "CTTypesetter")]
60    #[inline]
61    pub unsafe fn with_typesetter(typesetter: &CTTypesetter) -> CFRetained<CTFramesetter> {
62        extern "C-unwind" {
63            fn CTFramesetterCreateWithTypesetter(
64                typesetter: &CTTypesetter,
65            ) -> Option<NonNull<CTFramesetter>>;
66        }
67        let ret = unsafe { CTFramesetterCreateWithTypesetter(typesetter) };
68        let ret =
69            ret.expect("function was marked as returning non-null, but actually returned NULL");
70        unsafe { CFRetained::from_raw(ret) }
71    }
72
73    /// Creates an immutable framesetter object from an attributed
74    /// string.
75    ///
76    ///
77    /// The resultant framesetter object can be used to create and
78    /// fill text frames with the CTFramesetterCreateFrame call.
79    ///
80    ///
81    /// Parameter `attrString`: The attributed string to construct the framesetter with.
82    ///
83    ///
84    /// Returns: This function will return a reference to a CTFramesetter object.
85    #[doc(alias = "CTFramesetterCreateWithAttributedString")]
86    #[inline]
87    pub unsafe fn with_attributed_string(
88        attr_string: &CFAttributedString,
89    ) -> CFRetained<CTFramesetter> {
90        extern "C-unwind" {
91            fn CTFramesetterCreateWithAttributedString(
92                attr_string: &CFAttributedString,
93            ) -> Option<NonNull<CTFramesetter>>;
94        }
95        let ret = unsafe { CTFramesetterCreateWithAttributedString(attr_string) };
96        let ret =
97            ret.expect("function was marked as returning non-null, but actually returned NULL");
98        unsafe { CFRetained::from_raw(ret) }
99    }
100
101    /// Creates an immutable frame from a framesetter.
102    ///
103    ///
104    /// This call will create a frame full of glyphs in the shape of
105    /// the path provided by the "path" parameter. The framesetter
106    /// will continue to fill the frame until it either runs out of
107    /// text or it finds that text no longer fits.
108    ///
109    ///
110    /// Parameter `framesetter`: The framesetter that will be used to create the frame.
111    ///
112    ///
113    /// Parameter `stringRange`: The string range which the new frame will be based on. The
114    /// string range is a range over the string that was used to
115    /// create the framesetter. If the length portion of the range
116    /// is set to 0, then the framesetter will continue to add lines
117    /// until it runs out of text or space.
118    ///
119    ///
120    /// Parameter `path`: A CGPath object that specifies the shape which the frame will
121    /// take on.
122    ///
123    ///
124    /// Parameter `frameAttributes`: Additional attributes that control the frame filling process
125    /// can be specified here, or NULL if there are no such attributes.
126    /// See CTFrame.h for available attributes.
127    ///
128    ///
129    /// Returns: This function will return a reference to a new CTFrame object.
130    #[doc(alias = "CTFramesetterCreateFrame")]
131    #[cfg(all(feature = "CTFrame", feature = "objc2-core-graphics"))]
132    #[inline]
133    pub unsafe fn frame(
134        self: &CTFramesetter,
135        string_range: CFRange,
136        path: &CGPath,
137        frame_attributes: Option<&CFDictionary>,
138    ) -> CFRetained<CTFrame> {
139        extern "C-unwind" {
140            fn CTFramesetterCreateFrame(
141                framesetter: &CTFramesetter,
142                string_range: CFRange,
143                path: &CGPath,
144                frame_attributes: Option<&CFDictionary>,
145            ) -> Option<NonNull<CTFrame>>;
146        }
147        let ret = unsafe { CTFramesetterCreateFrame(self, string_range, path, frame_attributes) };
148        let ret =
149            ret.expect("function was marked as returning non-null, but actually returned NULL");
150        unsafe { CFRetained::from_raw(ret) }
151    }
152
153    /// Returns the typesetter object being used by the framesetter.
154    ///
155    ///
156    /// Each framesetter uses a typesetter internally to perform
157    /// line breaking and other contextual analysis based on the
158    /// characters in a string; this function returns the typesetter
159    /// being used by a particular framesetter if the caller would
160    /// like to perform other operations on that typesetter.
161    ///
162    ///
163    /// Parameter `framesetter`: The framesetter from which a typesetter is being requested.
164    ///
165    ///
166    /// Returns: This function will return a reference to a CTTypesetter
167    /// object, which should not be released by the caller.
168    #[doc(alias = "CTFramesetterGetTypesetter")]
169    #[cfg(feature = "CTTypesetter")]
170    #[inline]
171    pub unsafe fn typesetter(self: &CTFramesetter) -> CFRetained<CTTypesetter> {
172        extern "C-unwind" {
173            fn CTFramesetterGetTypesetter(
174                framesetter: &CTFramesetter,
175            ) -> Option<NonNull<CTTypesetter>>;
176        }
177        let ret = unsafe { CTFramesetterGetTypesetter(self) };
178        let ret =
179            ret.expect("function was marked as returning non-null, but actually returned NULL");
180        unsafe { CFRetained::retain(ret) }
181    }
182
183    /// Determines the frame size needed for a string range.
184    ///
185    ///
186    /// This function may be used to determine how much space is needed
187    /// to display a string, optionally by constraining the space along
188    /// either dimension.
189    ///
190    ///
191    /// Parameter `framesetter`: The framesetter that will be used for measuring the frame size.
192    ///
193    ///
194    /// Parameter `stringRange`: The string range to which the frame size will apply. The
195    /// string range is a range over the string that was used to
196    /// create the framesetter. If the length portion of the range
197    /// is set to 0, then the framesetter will continue to add lines
198    /// until it runs out of text or space.
199    ///
200    ///
201    /// Parameter `frameAttributes`: Additional attributes that control the frame filling process
202    /// can be specified here, or NULL if there are no such attributes.
203    ///
204    ///
205    /// Parameter `constraints`: The width and height to which the frame size will be constrained,
206    /// A value of CGFLOAT_MAX for either dimension indicates that it
207    /// should be treated as unconstrained.
208    ///
209    ///
210    /// Parameter `fitRange`: The range of the string that actually fit in the constrained size.
211    ///
212    ///
213    /// Returns: The actual dimensions for the given string range and constraints.
214    #[doc(alias = "CTFramesetterSuggestFrameSizeWithConstraints")]
215    #[inline]
216    pub unsafe fn suggest_frame_size_with_constraints(
217        self: &CTFramesetter,
218        string_range: CFRange,
219        frame_attributes: Option<&CFDictionary>,
220        constraints: CGSize,
221        fit_range: *mut CFRange,
222    ) -> CGSize {
223        extern "C-unwind" {
224            fn CTFramesetterSuggestFrameSizeWithConstraints(
225                framesetter: &CTFramesetter,
226                string_range: CFRange,
227                frame_attributes: Option<&CFDictionary>,
228                constraints: CGSize,
229                fit_range: *mut CFRange,
230            ) -> CGSize;
231        }
232        unsafe {
233            CTFramesetterSuggestFrameSizeWithConstraints(
234                self,
235                string_range,
236                frame_attributes,
237                constraints,
238                fit_range,
239            )
240        }
241    }
242}
243
244#[cfg(feature = "CTTypesetter")]
245#[deprecated = "renamed to `CTFramesetter::with_typesetter`"]
246#[inline]
247pub unsafe extern "C-unwind" fn CTFramesetterCreateWithTypesetter(
248    typesetter: &CTTypesetter,
249) -> CFRetained<CTFramesetter> {
250    extern "C-unwind" {
251        fn CTFramesetterCreateWithTypesetter(
252            typesetter: &CTTypesetter,
253        ) -> Option<NonNull<CTFramesetter>>;
254    }
255    let ret = unsafe { CTFramesetterCreateWithTypesetter(typesetter) };
256    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
257    unsafe { CFRetained::from_raw(ret) }
258}
259
260#[deprecated = "renamed to `CTFramesetter::with_attributed_string`"]
261#[inline]
262pub unsafe extern "C-unwind" fn CTFramesetterCreateWithAttributedString(
263    attr_string: &CFAttributedString,
264) -> CFRetained<CTFramesetter> {
265    extern "C-unwind" {
266        fn CTFramesetterCreateWithAttributedString(
267            attr_string: &CFAttributedString,
268        ) -> Option<NonNull<CTFramesetter>>;
269    }
270    let ret = unsafe { CTFramesetterCreateWithAttributedString(attr_string) };
271    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
272    unsafe { CFRetained::from_raw(ret) }
273}
274
275#[cfg(all(feature = "CTFrame", feature = "objc2-core-graphics"))]
276#[deprecated = "renamed to `CTFramesetter::frame`"]
277#[inline]
278pub unsafe extern "C-unwind" fn CTFramesetterCreateFrame(
279    framesetter: &CTFramesetter,
280    string_range: CFRange,
281    path: &CGPath,
282    frame_attributes: Option<&CFDictionary>,
283) -> CFRetained<CTFrame> {
284    extern "C-unwind" {
285        fn CTFramesetterCreateFrame(
286            framesetter: &CTFramesetter,
287            string_range: CFRange,
288            path: &CGPath,
289            frame_attributes: Option<&CFDictionary>,
290        ) -> Option<NonNull<CTFrame>>;
291    }
292    let ret =
293        unsafe { CTFramesetterCreateFrame(framesetter, string_range, path, frame_attributes) };
294    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
295    unsafe { CFRetained::from_raw(ret) }
296}
297
298#[cfg(feature = "CTTypesetter")]
299#[deprecated = "renamed to `CTFramesetter::typesetter`"]
300#[inline]
301pub unsafe extern "C-unwind" fn CTFramesetterGetTypesetter(
302    framesetter: &CTFramesetter,
303) -> CFRetained<CTTypesetter> {
304    extern "C-unwind" {
305        fn CTFramesetterGetTypesetter(framesetter: &CTFramesetter)
306            -> Option<NonNull<CTTypesetter>>;
307    }
308    let ret = unsafe { CTFramesetterGetTypesetter(framesetter) };
309    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
310    unsafe { CFRetained::retain(ret) }
311}
312
313extern "C-unwind" {
314    #[deprecated = "renamed to `CTFramesetter::suggest_frame_size_with_constraints`"]
315    pub fn CTFramesetterSuggestFrameSizeWithConstraints(
316        framesetter: &CTFramesetter,
317        string_range: CFRange,
318        frame_attributes: Option<&CFDictionary>,
319        constraints: CGSize,
320        fit_range: *mut CFRange,
321    ) -> CGSize;
322}