Function CTLineGetOffsetForStringIndex

Source
pub unsafe extern "C-unwind" fn CTLineGetOffsetForStringIndex(
    line: &CTLine,
    char_index: CFIndex,
    secondary_offset: *mut CGFloat,
) -> CGFloat
Available on crate feature CTLine only.
Expand description

Determines the graphical offset(s) for a string index.

This function returns the graphical offset(s) corresponding to a string index, suitable for movement between adjacent lines or for drawing a custom caret. For the former, the primary offset may be adjusted for any relative indentation of the two lines; a CGPoint constructed with the adjusted offset for its x value and 0.0 for its y value is suitable for passing to CTLineGetStringIndexForPosition. In either case, the primary offset corresponds to the portion of the caret that represents the visual insertion location for a character whose direction matches the line’s writing direction.

Parameter line: The line from which the offset is requested.

Parameter charIndex: The string index corresponding to the desired position.

Parameter secondaryOffset: An output parameter that will be set to the secondary offset along the baseline for charIndex. When a single caret is sufficient for a string index, this value will be the same as the primary offset, which is the return value of this function. This parameter may be NULL.

Returns: The primary offset along the baseline for charIndex, or 0.0 in the event of failure.