Class

TextLayoutInput

The data class which holds the set of parameters of the text layout computation.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Common
class TextLayoutInput
private constructor(
    /** The text used for computing text layout. */
    val text: AnnotatedString,

    /** The text layout used for computing this text layout. */
    val style: TextStyle,

    /**
     * A list of [Placeholder]s inserted into text layout that reserves space to embed icons or
     * custom emojis. A list of bounding boxes will be returned in
     * [TextLayoutResult.placeholderRects] that corresponds to this input.
     *
     * @see TextLayoutResult.placeholderRects
     * @see MultiParagraph
     * @see MultiParagraphIntrinsics
     */
    val placeholders: List<AnnotatedString.Range<Placeholder>>,

    /** The maxLines param used for computing this text layout. */
    val maxLines: Int,

    /** The maxLines param used for computing this text layout. */
    val softWrap: Boolean,

    /** The overflow param used for computing this text layout */
    val overflow: TextOverflow,

    /** The density param used for computing this text layout. */
    val density: Density,

    /** The layout direction used for computing this text layout. */
    val layoutDirection: LayoutDirection,

    /**
     * The font resource loader used for computing this text layout.
     *
     * This is no longer used.
     *
     * @see fontFamilyResolver
     */
    @Suppress("DEPRECATION") resourceLoader: Font.ResourceLoader?,

    /** The font resolver used for computing this text layout. */
    val fontFamilyResolver: FontFamily.Resolver,

    /** The minimum width provided while calculating this text layout. */
    val constraints: Constraints,
)

The data class which holds the set of parameters of the text layout computation.

Secondary Constructors

constructor(
    text: AnnotatedString,
    style: TextStyle,
    placeholders: List<AnnotatedString.Range<Placeholder>>,
    maxLines: Int,
    softWrap: Boolean,
    overflow: TextOverflow,
    density: Density,
    layoutDirection: LayoutDirection,
    resourceLoader: Font.ResourceLoader,
    constraints: Constraints,
) : this(
    text,
    style,
    placeholders,
    maxLines,
    softWrap,
    overflow,
    density,
    layoutDirection,
    resourceLoader,
    createFontFamilyResolver(resourceLoader),
    constraints,
)
constructor(
    text: AnnotatedString,
    style: TextStyle,
    placeholders: List<AnnotatedString.Range<Placeholder>>,
    maxLines: Int,
    softWrap: Boolean,
    overflow: TextOverflow,
    density: Density,
    layoutDirection: LayoutDirection,
    fontFamilyResolver: FontFamily.Resolver,
    constraints: Constraints,
) : this(
    text,
    style,
    placeholders,
    maxLines,
    softWrap,
    overflow,
    density,
    layoutDirection,
    @Suppress("DEPRECATION") null,
    fontFamilyResolver,
    constraints,
)

Properties

Common
Deprecated Replaced with FontFamily.Resolver
val resourceLoader: Font.ResourceLoader

Functions

copy

fun copy(
        text: AnnotatedString = this.text,
        style: TextStyle = this.style,
        placeholders: List<AnnotatedString.Range<Placeholder>> = this.placeholders,
        maxLines: Int = this.maxLines,
        softWrap: Boolean = this.softWrap,
        overflow: TextOverflow = this.overflow,
        density: Density = this.density,
        layoutDirection: LayoutDirection = this.layoutDirection,
        @Suppress("DEPRECATION") resourceLoader: Font.ResourceLoader = this.resourceLoader,
        constraints: Constraints = this.constraints,
    ): TextLayoutInput