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