ParagraphLayouter



The purpose of this class is to store already built paragraph and pass it between different internal entities (from SkiaParagraphIntrinsics to SkiaParagraph).

An alternative to passing and reusing existed paragraph is to build it again, but it is 2.5x slower.

LayoutedParagraph should has only one owner to avoid concurrent usage.

Tests:

val text = (1..100000).joinToString(" ") reusedParagraph.layout(300f): 116.848500ms builder.build().layout(300f): 288.302300ms

text = (1..10000).joinToString(" ") reusedParagraph.layout(300f): 10.004400ms builder.build().layout(300f): 23.421500ms

Summary

Public constructors

ParagraphLayouter(
    text: String,
    textDirection: ResolvedTextDirection,
    style: TextStyle,
    spanStyles: List<AnnotatedString.Range<SpanStyle>>,
    placeholders: List<AnnotatedString.Range<Placeholder>>,
    density: Density,
    fontFamilyResolver: FontFamily.Resolver
)
android

Public functions

Paragraph
layoutParagraph(
    width: Float,
    maxLines: Int,
    ellipsis: String,
    color: Color,
    shadow: Shadow?,
    textDecoration: TextDecoration?
)
android

Public properties

Float
android
String
android

Public constructors

ParagraphLayouter

ParagraphLayouter(
    text: String,
    textDirection: ResolvedTextDirection,
    style: TextStyle,
    spanStyles: List<AnnotatedString.Range<SpanStyle>>,
    placeholders: List<AnnotatedString.Range<Placeholder>>,
    density: Density,
    fontFamilyResolver: FontFamily.Resolver
)

Public functions

layoutParagraph

fun layoutParagraph(
    width: Float = this.width,
    maxLines: Int = builder.maxLines,
    ellipsis: String = builder.ellipsis,
    color: Color = builder.textStyle.color,
    shadow: Shadow? = builder.textStyle.shadow,
    textDecoration: TextDecoration? = builder.textStyle.textDecoration
): Paragraph

Public properties

defaultHeight

val defaultHeightFloat

text

val textString