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