objc2_core_text/generated/
CTLine.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10#[cfg(feature = "objc2-core-graphics")]
11use objc2_core_graphics::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctline?language=objc)
16#[doc(alias = "CTLineRef")]
17#[repr(C)]
18pub struct CTLine {
19    inner: [u8; 0],
20    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
21}
22
23cf_type!(
24    unsafe impl CTLine {}
25);
26#[cfg(feature = "objc2")]
27cf_objc2_type!(
28    unsafe impl RefEncode<"__CTLine"> for CTLine {}
29);
30
31/// Options for CTLineGetBoundsWithOptions.
32///
33///
34/// Passing 0 (no options) returns the typographic bounds,
35/// including typographic leading and shifts.
36///
37///
38/// Pass this option to exclude typographic leading.
39///
40///
41/// Pass this option to ignore cross-stream shifts due to
42/// positioning (such as kerning or baseline alignment).
43///
44///
45/// Normally line bounds include all glyphs; pass this option to
46/// treat standard punctuation hanging off either end of the line
47/// as fully hanging.
48///
49///
50/// Pass this option to use glyph path bounds rather than the
51/// default typographic bounds.
52///
53///
54/// Pass this option to use optical bounds, as determined by
55/// CTFontGetOpticalBoundsForGlyphs. This option overrides
56/// kCTLineBoundsUseGlyphPathBounds.
57///
58///
59/// Pass this option to include additional space based on common
60/// glyph sequences for various languages. The result is intended
61/// to be used when drawing to avoid clipping that may be caused
62/// by the typographic bounds. This option does not have any effect
63/// when used with kCTLineBoundsUseGlyphPathBounds.
64///
65/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctlineboundsoptions?language=objc)
66// NS_OPTIONS
67#[repr(transparent)]
68#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
69pub struct CTLineBoundsOptions(pub CFOptionFlags);
70bitflags::bitflags! {
71    impl CTLineBoundsOptions: CFOptionFlags {
72        #[doc(alias = "kCTLineBoundsExcludeTypographicLeading")]
73        const ExcludeTypographicLeading = 1<<0;
74        #[doc(alias = "kCTLineBoundsExcludeTypographicShifts")]
75        const ExcludeTypographicShifts = 1<<1;
76        #[doc(alias = "kCTLineBoundsUseHangingPunctuation")]
77        const UseHangingPunctuation = 1<<2;
78        #[doc(alias = "kCTLineBoundsUseGlyphPathBounds")]
79        const UseGlyphPathBounds = 1<<3;
80        #[doc(alias = "kCTLineBoundsUseOpticalBounds")]
81        const UseOpticalBounds = 1<<4;
82        #[doc(alias = "kCTLineBoundsIncludeLanguageExtents")]
83        const IncludeLanguageExtents = 1<<5;
84    }
85}
86
87#[cfg(feature = "objc2")]
88unsafe impl Encode for CTLineBoundsOptions {
89    const ENCODING: Encoding = CFOptionFlags::ENCODING;
90}
91
92#[cfg(feature = "objc2")]
93unsafe impl RefEncode for CTLineBoundsOptions {
94    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
95}
96
97/// Truncation types required by CTLineCreateTruncatedLine. These
98/// will tell truncation engine which type of truncation is being
99/// requested.
100///
101///
102/// Truncate at the beginning of the line, leaving the end portion
103/// visible.
104///
105///
106/// Truncate at the end of the line, leaving the start portion
107/// visible.
108///
109///
110/// Truncate in the middle of the line, leaving both the start
111/// and the end portions visible.
112///
113/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctlinetruncationtype?language=objc)
114// NS_ENUM
115#[repr(transparent)]
116#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
117pub struct CTLineTruncationType(pub u32);
118impl CTLineTruncationType {
119    #[doc(alias = "kCTLineTruncationStart")]
120    pub const Start: Self = Self(0);
121    #[doc(alias = "kCTLineTruncationEnd")]
122    pub const End: Self = Self(1);
123    #[doc(alias = "kCTLineTruncationMiddle")]
124    pub const Middle: Self = Self(2);
125}
126
127#[cfg(feature = "objc2")]
128unsafe impl Encode for CTLineTruncationType {
129    const ENCODING: Encoding = u32::ENCODING;
130}
131
132#[cfg(feature = "objc2")]
133unsafe impl RefEncode for CTLineTruncationType {
134    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
135}
136
137unsafe impl ConcreteType for CTLine {
138    /// Returns the CFType of the line object
139    #[doc(alias = "CTLineGetTypeID")]
140    #[inline]
141    fn type_id() -> CFTypeID {
142        extern "C-unwind" {
143            fn CTLineGetTypeID() -> CFTypeID;
144        }
145        unsafe { CTLineGetTypeID() }
146    }
147}
148
149impl CTLine {
150    /// Creates a single immutable line object directly from an
151    /// attributed string.
152    ///
153    ///
154    /// This will allow clients who need very simple line generation to
155    /// create a line without needing to create a typesetter object. The
156    /// typesetting will be done under the hood. Without a typesetter
157    /// object, the line cannot be properly broken. However, for simple
158    /// things like text labels and other things, this is not an issue.
159    ///
160    ///
161    /// Parameter `attrString`: The attributed string which the line will be created for.
162    ///
163    ///
164    /// Returns: This function will return a reference to a CTLine object.
165    #[doc(alias = "CTLineCreateWithAttributedString")]
166    #[inline]
167    pub unsafe fn with_attributed_string(attr_string: &CFAttributedString) -> CFRetained<CTLine> {
168        extern "C-unwind" {
169            fn CTLineCreateWithAttributedString(
170                attr_string: &CFAttributedString,
171            ) -> Option<NonNull<CTLine>>;
172        }
173        let ret = unsafe { CTLineCreateWithAttributedString(attr_string) };
174        let ret =
175            ret.expect("function was marked as returning non-null, but actually returned NULL");
176        unsafe { CFRetained::from_raw(ret) }
177    }
178
179    /// Creates a truncated line from an existing line.
180    ///
181    ///
182    /// Parameter `line`: The line that you want to create a truncated line for.
183    ///
184    ///
185    /// Parameter `width`: The width at which truncation will begin. The line will be
186    /// truncated if its width is greater than the width passed in this.
187    ///
188    ///
189    /// Parameter `truncationType`: The type of truncation to perform if needed.
190    ///
191    ///
192    /// Parameter `truncationToken`: This token will be added to the point where truncation took place
193    /// to indicate that the line was truncated. Usually, the truncation
194    /// token is the ellipsis character (U+2026). If this parameter is
195    /// set to NULL, then no truncation token is used, and the line is
196    /// simply cut off. The line specified in truncationToken should have
197    /// a width less than the width specified by the width parameter. If
198    /// the width of the line specified in truncationToken is greater,
199    /// this function will return NULL if truncation is needed.
200    ///
201    ///
202    /// Returns: This function will return a reference to a truncated CTLine
203    /// object if the call was successful. Otherwise, it will return
204    /// NULL.
205    #[doc(alias = "CTLineCreateTruncatedLine")]
206    #[inline]
207    pub unsafe fn truncated_line(
208        &self,
209        width: c_double,
210        truncation_type: CTLineTruncationType,
211        truncation_token: Option<&CTLine>,
212    ) -> Option<CFRetained<CTLine>> {
213        extern "C-unwind" {
214            fn CTLineCreateTruncatedLine(
215                line: &CTLine,
216                width: c_double,
217                truncation_type: CTLineTruncationType,
218                truncation_token: Option<&CTLine>,
219            ) -> Option<NonNull<CTLine>>;
220        }
221        let ret =
222            unsafe { CTLineCreateTruncatedLine(self, width, truncation_type, truncation_token) };
223        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
224    }
225
226    /// Creates a justified line from an existing line.
227    ///
228    ///
229    /// Parameter `line`: The line that you want to create a justified line for.
230    ///
231    ///
232    /// Parameter `justificationFactor`: Allows for full or partial justification. When set to 1.0 or
233    /// greater indicates, full justification will be performed. If less
234    /// than 1.0, varying degrees of partial justification will be
235    /// performed. If set to 0 or less, then no justification will be
236    /// performed.
237    ///
238    ///
239    /// Parameter `justificationWidth`: The width to which the resultant line will be justified. If
240    /// justificationWidth is less than the actual width of the line,
241    /// then negative justification will be performed ("text squishing").
242    ///
243    ///
244    /// Returns: This function will return a reference to a justified CTLine
245    /// object if the call was successful. Otherwise, it will return
246    /// NULL.
247    #[doc(alias = "CTLineCreateJustifiedLine")]
248    #[inline]
249    pub unsafe fn justified_line(
250        &self,
251        justification_factor: CGFloat,
252        justification_width: c_double,
253    ) -> Option<CFRetained<CTLine>> {
254        extern "C-unwind" {
255            fn CTLineCreateJustifiedLine(
256                line: &CTLine,
257                justification_factor: CGFloat,
258                justification_width: c_double,
259            ) -> Option<NonNull<CTLine>>;
260        }
261        let ret =
262            unsafe { CTLineCreateJustifiedLine(self, justification_factor, justification_width) };
263        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
264    }
265
266    /// Returns the total glyph count for the line object.
267    ///
268    ///
269    /// The total glyph count is equal to the sum of all of the glyphs in
270    /// the glyph runs forming the line.
271    ///
272    ///
273    /// Parameter `line`: The line that you want to obtain the glyph count for.
274    ///
275    ///
276    /// Returns: The total glyph count for the line passed in.
277    #[doc(alias = "CTLineGetGlyphCount")]
278    #[inline]
279    pub unsafe fn glyph_count(&self) -> CFIndex {
280        extern "C-unwind" {
281            fn CTLineGetGlyphCount(line: &CTLine) -> CFIndex;
282        }
283        unsafe { CTLineGetGlyphCount(self) }
284    }
285
286    /// Returns the array of glyph runs that make up the line object.
287    ///
288    ///
289    /// Parameter `line`: The line that you want to obtain the glyph run array for.
290    ///
291    ///
292    /// Returns: A CFArrayRef containing the CTRun objects that make up the line.
293    #[doc(alias = "CTLineGetGlyphRuns")]
294    #[inline]
295    pub unsafe fn glyph_runs(&self) -> CFRetained<CFArray> {
296        extern "C-unwind" {
297            fn CTLineGetGlyphRuns(line: &CTLine) -> Option<NonNull<CFArray>>;
298        }
299        let ret = unsafe { CTLineGetGlyphRuns(self) };
300        let ret =
301            ret.expect("function was marked as returning non-null, but actually returned NULL");
302        unsafe { CFRetained::retain(ret) }
303    }
304
305    /// Gets the range of characters that originally spawned the glyphs
306    /// in the line.
307    ///
308    ///
309    /// Parameter `line`: The line that you want to obtain the string range from.
310    ///
311    ///
312    /// Returns: A CFRange that contains the range over the backing store string
313    /// that spawned the glyphs. If the function fails for any reason, an
314    /// empty range will be returned.
315    #[doc(alias = "CTLineGetStringRange")]
316    #[inline]
317    pub unsafe fn string_range(&self) -> CFRange {
318        extern "C-unwind" {
319            fn CTLineGetStringRange(line: &CTLine) -> CFRange;
320        }
321        unsafe { CTLineGetStringRange(self) }
322    }
323
324    /// Gets the pen offset required to draw flush text.
325    ///
326    ///
327    /// Parameter `line`: The line that you want to obtain a flush position from.
328    ///
329    ///
330    /// Parameter `flushFactor`: Specifies what kind of flushness you want. A flushFactor of 0 or
331    /// less indicates left flush. A flushFactor of 1.0 or more indicates
332    /// right flush. Flush factors between 0 and 1.0 indicate varying
333    /// degrees of center flush, with a value of 0.5 being totally center
334    /// flush.
335    ///
336    ///
337    /// Parameter `flushWidth`: Specifies the width that the flushness operation should apply to.
338    ///
339    ///
340    /// Returns: A value which can be used to offset the current pen position for
341    /// the flush operation.
342    #[doc(alias = "CTLineGetPenOffsetForFlush")]
343    #[inline]
344    pub unsafe fn pen_offset_for_flush(
345        &self,
346        flush_factor: CGFloat,
347        flush_width: c_double,
348    ) -> c_double {
349        extern "C-unwind" {
350            fn CTLineGetPenOffsetForFlush(
351                line: &CTLine,
352                flush_factor: CGFloat,
353                flush_width: c_double,
354            ) -> c_double;
355        }
356        unsafe { CTLineGetPenOffsetForFlush(self, flush_factor, flush_width) }
357    }
358
359    /// Draws a line.
360    ///
361    ///
362    /// This is a convenience call, since the line could be drawn
363    /// run-by-run by getting the glyph runs and accessing the glyphs out
364    /// of them. This call may leave the graphics context in any state and
365    /// does not flush the context after drawing. This call also expects
366    /// a text matrix with `y` values increasing from bottom to top; a
367    /// flipped text matrix may result in misplaced diacritics.
368    ///
369    ///
370    /// Parameter `line`: The line that you want to draw.
371    ///
372    ///
373    /// Parameter `context`: The context to which the line will be drawn.
374    #[doc(alias = "CTLineDraw")]
375    #[cfg(feature = "objc2-core-graphics")]
376    #[inline]
377    pub unsafe fn draw(&self, context: &CGContext) {
378        extern "C-unwind" {
379            fn CTLineDraw(line: &CTLine, context: &CGContext);
380        }
381        unsafe { CTLineDraw(self, context) }
382    }
383
384    /// Calculates the typographic bounds for a line.
385    ///
386    ///
387    /// A line's typographic width is the distance to the rightmost
388    /// glyph advance width edge. Note that this distance includes
389    /// trailing whitespace glyphs.
390    ///
391    ///
392    /// Parameter `line`: The line that you want to calculate the typographic bounds for.
393    ///
394    ///
395    /// Parameter `ascent`: Upon return, this parameter will contain the ascent of the line.
396    /// This may be set to NULL if not needed.
397    ///
398    ///
399    /// Parameter `descent`: Upon return, this parameter will contain the descent of the line.
400    /// This may be set to NULL if not needed.
401    ///
402    ///
403    /// Parameter `leading`: Upon return, this parameter will contain the leading of the line.
404    /// This may be set to NULL if not needed.
405    ///
406    ///
407    /// Returns: The typographic width of the line. If line is invalid, this
408    /// function will always return zero.
409    ///
410    ///
411    /// See also: CTLineGetTrailingWhitespaceWidth
412    ///
413    /// # Safety
414    ///
415    /// - `ascent` must be a valid pointer or null.
416    /// - `descent` must be a valid pointer or null.
417    /// - `leading` must be a valid pointer or null.
418    #[doc(alias = "CTLineGetTypographicBounds")]
419    #[inline]
420    pub unsafe fn typographic_bounds(
421        &self,
422        ascent: *mut CGFloat,
423        descent: *mut CGFloat,
424        leading: *mut CGFloat,
425    ) -> c_double {
426        extern "C-unwind" {
427            fn CTLineGetTypographicBounds(
428                line: &CTLine,
429                ascent: *mut CGFloat,
430                descent: *mut CGFloat,
431                leading: *mut CGFloat,
432            ) -> c_double;
433        }
434        unsafe { CTLineGetTypographicBounds(self, ascent, descent, leading) }
435    }
436
437    /// Calculates the bounds for a line.
438    ///
439    ///
440    /// Parameter `line`: The line that you want to calculate the bounds for.
441    ///
442    ///
443    /// Parameter `options`: Desired options or 0 if none.
444    ///
445    ///
446    /// Returns: The bounds of the line as specified by the type and options,
447    /// such that the coordinate origin is coincident with the line
448    /// origin and the rect origin is at the bottom left. If the line
449    /// is invalid this function will return CGRectNull.
450    #[doc(alias = "CTLineGetBoundsWithOptions")]
451    #[inline]
452    pub unsafe fn bounds_with_options(&self, options: CTLineBoundsOptions) -> CGRect {
453        extern "C-unwind" {
454            fn CTLineGetBoundsWithOptions(line: &CTLine, options: CTLineBoundsOptions) -> CGRect;
455        }
456        unsafe { CTLineGetBoundsWithOptions(self, options) }
457    }
458
459    /// Calculates the trailing whitespace width for a line.
460    ///
461    ///
462    /// Parameter `line`: The line that you want to calculate the trailing whitespace width
463    /// for. Creating a line for a width can result in a line that is
464    /// actually longer than the desired width due to trailing
465    /// whitespace. Normally this is not an issue due to whitespace being
466    /// invisible, but this function may be used to determine what amount
467    /// of a line's width is due to trailing whitespace.
468    ///
469    ///
470    /// Returns: The width of the line's trailing whitespace. If line is invalid,
471    /// this function will always return zero.
472    #[doc(alias = "CTLineGetTrailingWhitespaceWidth")]
473    #[inline]
474    pub unsafe fn trailing_whitespace_width(&self) -> c_double {
475        extern "C-unwind" {
476            fn CTLineGetTrailingWhitespaceWidth(line: &CTLine) -> c_double;
477        }
478        unsafe { CTLineGetTrailingWhitespaceWidth(self) }
479    }
480
481    /// Calculates the image bounds for a line.
482    ///
483    ///
484    /// The image bounds for a line is the union of all non-empty glyph
485    /// bounding rects, each positioned as it would be if drawn using
486    /// CTLineDraw using the current context. Note that the result is
487    /// ideal and does not account for raster coverage due to rendering.
488    /// This function is purely a convenience for using glyphs as an
489    /// image and should not be used for typographic purposes.
490    ///
491    ///
492    /// Parameter `line`: The line that you want to calculate the image bounds for.
493    ///
494    ///
495    /// Parameter `context`: The context which the image bounds will be calculated for or NULL,
496    /// in which case the bounds are relative to CGPointZero.
497    ///
498    ///
499    /// Returns: A rectangle that tightly encloses the paths of the line's glyphs,
500    /// which will be translated by the supplied context's text position.
501    /// If the line is invalid, CGRectNull will be returned.
502    ///
503    ///
504    /// See also: CTLineGetTypographicBounds
505    ///
506    /// See also: CTLineGetBoundsWithOptions
507    ///
508    /// See also: CTLineGetPenOffsetForFlush
509    #[doc(alias = "CTLineGetImageBounds")]
510    #[cfg(feature = "objc2-core-graphics")]
511    #[inline]
512    pub unsafe fn image_bounds(&self, context: Option<&CGContext>) -> CGRect {
513        extern "C-unwind" {
514            fn CTLineGetImageBounds(line: &CTLine, context: Option<&CGContext>) -> CGRect;
515        }
516        unsafe { CTLineGetImageBounds(self, context) }
517    }
518
519    /// Performs hit testing.
520    ///
521    ///
522    /// This function can be used to determine the string index for a
523    /// mouse click or other event. This string index corresponds to the
524    /// character before which the next character should be inserted.
525    /// This determination is made by analyzing the string from which a
526    /// typesetter was created and the corresponding glyphs as embodied
527    /// by a particular line.
528    ///
529    ///
530    /// Parameter `line`: The line being examined.
531    ///
532    ///
533    /// Parameter `position`: The location of the mouse click relative to the line's origin.
534    ///
535    ///
536    /// Returns: The string index for the position. Relative to the line's string
537    /// range, this value will be no less than the first string index and
538    /// no greater than one plus the last string index. In the event of
539    /// failure, this function will return kCFNotFound.
540    #[doc(alias = "CTLineGetStringIndexForPosition")]
541    #[inline]
542    pub unsafe fn string_index_for_position(&self, position: CGPoint) -> CFIndex {
543        extern "C-unwind" {
544            fn CTLineGetStringIndexForPosition(line: &CTLine, position: CGPoint) -> CFIndex;
545        }
546        unsafe { CTLineGetStringIndexForPosition(self, position) }
547    }
548
549    /// Determines the graphical offset(s) for a string index.
550    ///
551    ///
552    /// This function returns the graphical offset(s) corresponding to
553    /// a string index, suitable for movement between adjacent lines or
554    /// for drawing a custom caret. For the former, the primary offset
555    /// may be adjusted for any relative indentation of the two lines;
556    /// a CGPoint constructed with the adjusted offset for its x value
557    /// and 0.0 for its y value is suitable for passing to
558    /// CTLineGetStringIndexForPosition. In either case, the primary
559    /// offset corresponds to the portion of the caret that represents
560    /// the visual insertion location for a character whose direction
561    /// matches the line's writing direction.
562    ///
563    ///
564    /// Parameter `line`: The line from which the offset is requested.
565    ///
566    ///
567    /// Parameter `charIndex`: The string index corresponding to the desired position.
568    ///
569    ///
570    /// Parameter `secondaryOffset`: An output parameter that will be set to the secondary offset
571    /// along the baseline for charIndex. When a single caret is
572    /// sufficient for a string index, this value will be the same as
573    /// the primary offset, which is the return value of this function.
574    /// This parameter may be NULL.
575    ///
576    ///
577    /// Returns: The primary offset along the baseline for charIndex, or 0.0 in
578    /// the event of failure.
579    ///
580    /// # Safety
581    ///
582    /// `secondary_offset` must be a valid pointer or null.
583    #[doc(alias = "CTLineGetOffsetForStringIndex")]
584    #[inline]
585    pub unsafe fn offset_for_string_index(
586        &self,
587        char_index: CFIndex,
588        secondary_offset: *mut CGFloat,
589    ) -> CGFloat {
590        extern "C-unwind" {
591            fn CTLineGetOffsetForStringIndex(
592                line: &CTLine,
593                char_index: CFIndex,
594                secondary_offset: *mut CGFloat,
595            ) -> CGFloat;
596        }
597        unsafe { CTLineGetOffsetForStringIndex(self, char_index, secondary_offset) }
598    }
599
600    /// Enumerates caret offsets for characters in a line.
601    ///
602    ///
603    /// The provided block is invoked once for each logical caret edge in the line, in left-to-right visual order.
604    ///
605    ///
606    /// Parameter `block`: The offset parameter is relative to the line origin. The leadingEdge parameter of this block refers to logical order.
607    #[doc(alias = "CTLineEnumerateCaretOffsets")]
608    #[cfg(feature = "block2")]
609    #[inline]
610    pub unsafe fn enumerate_caret_offsets(
611        &self,
612        block: &block2::DynBlock<dyn Fn(c_double, CFIndex, bool, NonNull<bool>)>,
613    ) {
614        extern "C-unwind" {
615            fn CTLineEnumerateCaretOffsets(
616                line: &CTLine,
617                block: &block2::DynBlock<dyn Fn(c_double, CFIndex, bool, NonNull<bool>)>,
618            );
619        }
620        unsafe { CTLineEnumerateCaretOffsets(self, block) }
621    }
622}
623
624#[deprecated = "renamed to `CTLine::with_attributed_string`"]
625#[inline]
626pub unsafe extern "C-unwind" fn CTLineCreateWithAttributedString(
627    attr_string: &CFAttributedString,
628) -> CFRetained<CTLine> {
629    extern "C-unwind" {
630        fn CTLineCreateWithAttributedString(
631            attr_string: &CFAttributedString,
632        ) -> Option<NonNull<CTLine>>;
633    }
634    let ret = unsafe { CTLineCreateWithAttributedString(attr_string) };
635    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
636    unsafe { CFRetained::from_raw(ret) }
637}
638
639#[deprecated = "renamed to `CTLine::truncated_line`"]
640#[inline]
641pub unsafe extern "C-unwind" fn CTLineCreateTruncatedLine(
642    line: &CTLine,
643    width: c_double,
644    truncation_type: CTLineTruncationType,
645    truncation_token: Option<&CTLine>,
646) -> Option<CFRetained<CTLine>> {
647    extern "C-unwind" {
648        fn CTLineCreateTruncatedLine(
649            line: &CTLine,
650            width: c_double,
651            truncation_type: CTLineTruncationType,
652            truncation_token: Option<&CTLine>,
653        ) -> Option<NonNull<CTLine>>;
654    }
655    let ret = unsafe { CTLineCreateTruncatedLine(line, width, truncation_type, truncation_token) };
656    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
657}
658
659#[deprecated = "renamed to `CTLine::justified_line`"]
660#[inline]
661pub unsafe extern "C-unwind" fn CTLineCreateJustifiedLine(
662    line: &CTLine,
663    justification_factor: CGFloat,
664    justification_width: c_double,
665) -> Option<CFRetained<CTLine>> {
666    extern "C-unwind" {
667        fn CTLineCreateJustifiedLine(
668            line: &CTLine,
669            justification_factor: CGFloat,
670            justification_width: c_double,
671        ) -> Option<NonNull<CTLine>>;
672    }
673    let ret = unsafe { CTLineCreateJustifiedLine(line, justification_factor, justification_width) };
674    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
675}
676
677extern "C-unwind" {
678    #[deprecated = "renamed to `CTLine::glyph_count`"]
679    pub fn CTLineGetGlyphCount(line: &CTLine) -> CFIndex;
680}
681
682#[deprecated = "renamed to `CTLine::glyph_runs`"]
683#[inline]
684pub unsafe extern "C-unwind" fn CTLineGetGlyphRuns(line: &CTLine) -> CFRetained<CFArray> {
685    extern "C-unwind" {
686        fn CTLineGetGlyphRuns(line: &CTLine) -> Option<NonNull<CFArray>>;
687    }
688    let ret = unsafe { CTLineGetGlyphRuns(line) };
689    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
690    unsafe { CFRetained::retain(ret) }
691}
692
693extern "C-unwind" {
694    #[deprecated = "renamed to `CTLine::string_range`"]
695    pub fn CTLineGetStringRange(line: &CTLine) -> CFRange;
696}
697
698extern "C-unwind" {
699    #[deprecated = "renamed to `CTLine::pen_offset_for_flush`"]
700    pub fn CTLineGetPenOffsetForFlush(
701        line: &CTLine,
702        flush_factor: CGFloat,
703        flush_width: c_double,
704    ) -> c_double;
705}
706
707extern "C-unwind" {
708    #[cfg(feature = "objc2-core-graphics")]
709    #[deprecated = "renamed to `CTLine::draw`"]
710    pub fn CTLineDraw(line: &CTLine, context: &CGContext);
711}
712
713extern "C-unwind" {
714    #[deprecated = "renamed to `CTLine::typographic_bounds`"]
715    pub fn CTLineGetTypographicBounds(
716        line: &CTLine,
717        ascent: *mut CGFloat,
718        descent: *mut CGFloat,
719        leading: *mut CGFloat,
720    ) -> c_double;
721}
722
723extern "C-unwind" {
724    #[deprecated = "renamed to `CTLine::bounds_with_options`"]
725    pub fn CTLineGetBoundsWithOptions(line: &CTLine, options: CTLineBoundsOptions) -> CGRect;
726}
727
728extern "C-unwind" {
729    #[deprecated = "renamed to `CTLine::trailing_whitespace_width`"]
730    pub fn CTLineGetTrailingWhitespaceWidth(line: &CTLine) -> c_double;
731}
732
733extern "C-unwind" {
734    #[cfg(feature = "objc2-core-graphics")]
735    #[deprecated = "renamed to `CTLine::image_bounds`"]
736    pub fn CTLineGetImageBounds(line: &CTLine, context: Option<&CGContext>) -> CGRect;
737}
738
739extern "C-unwind" {
740    #[deprecated = "renamed to `CTLine::string_index_for_position`"]
741    pub fn CTLineGetStringIndexForPosition(line: &CTLine, position: CGPoint) -> CFIndex;
742}
743
744extern "C-unwind" {
745    #[deprecated = "renamed to `CTLine::offset_for_string_index`"]
746    pub fn CTLineGetOffsetForStringIndex(
747        line: &CTLine,
748        char_index: CFIndex,
749        secondary_offset: *mut CGFloat,
750    ) -> CGFloat;
751}
752
753extern "C-unwind" {
754    #[cfg(feature = "block2")]
755    #[deprecated = "renamed to `CTLine::enumerate_caret_offsets`"]
756    pub fn CTLineEnumerateCaretOffsets(
757        line: &CTLine,
758        block: &block2::DynBlock<dyn Fn(c_double, CFIndex, bool, NonNull<bool>)>,
759    );
760}