Google is committed to advancing racial equity for Black communities. See how.

FontListFontFamily

@Immutable data class FontListFontFamily : FileBasedFontFamily, List<Font>
kotlin.Any
   ↳ androidx.compose.ui.text.font.FontFamily
   ↳ androidx.compose.ui.text.font.FileBasedFontFamily
   ↳ androidx.compose.ui.text.font.FontListFontFamily

Defines a font family with list of Font.

import androidx.compose.material.Text

Text(
    text = "Demo Text sans-serif",
    fontFamily = FontFamily.SansSerif
)
import androidx.compose.material.Text
import androidx.compose.ui.text.font.font
import androidx.compose.ui.text.font.fontFamily

val fontFamily = fontFamily(
    font(
        resId = R.font.my_font_400_regular,
        weight = FontWeight.W400,
        style = FontStyle.Normal
    ),
    font(
        resId = R.font.my_font_400_italic,
        weight = FontWeight.W400,
        style = FontStyle.Italic
    )
)
Text(text = "Demo Text", fontFamily = fontFamily)

Summary

Public constructors
<init>(fonts: List<Font>)

Defines a font family with list of Font.

Inherited extension functions
From androidx.compose.ui.util.kotlin.collections.List
Boolean
List<T>.fastAll(predicate: (T) -> Boolean)

Returns true if all elements match the given predicate.

Boolean
List<T>.fastAny(predicate: (T) -> Boolean)

Returns true if at least one element matches the given predicate.

T?
List<T>.fastFirstOrNull(predicate: (T) -> Boolean)

Returns the first value that predicate returns true for or null if nothing matches.

Unit
List<T>.fastForEach(action: (T) -> Unit)

Iterates through a List using the index and calls action for each item.

Unit
List<T>.fastForEachIndexed(action: (Int, T) -> Unit)

Iterates through a List using the index and calls action for each item.

List<R>
List<T>.fastMap(transform: (T) -> R)

Returns a list containing the results of applying the given transform function to each element in the original collection.

C
List<T>.fastMapTo(destination: C, transform: (T) -> R)

Applies the given transform function to each element of the original collection and appends the results to the given destination.

T?
List<T>.fastMaxBy(selector: (T) -> R)

Returns the first element yielding the largest value of the given function or null if there are no elements.

Int
List<T>.fastSumBy(selector: (T) -> Int)

Returns the sum of all values produced by selector function applied to each element in the list.

From androidx.compose.runtime.kotlin.collections.Collection
SnapshotStateList<T>

Create an instance of MutableList from a collection that is observerable and can be snapshot.

Properties
List<Font>

Public constructors

<init>

FontListFontFamily(fonts: List<Font>)

Defines a font family with list of Font.

import androidx.compose.material.Text

Text(
    text = "Demo Text sans-serif",
    fontFamily = FontFamily.SansSerif
)
import androidx.compose.material.Text
import androidx.compose.ui.text.font.font
import androidx.compose.ui.text.font.fontFamily

val fontFamily = fontFamily(
    font(
        resId = R.font.my_font_400_regular,
        weight = FontWeight.W400,
        style = FontStyle.Normal
    ),
    font(
        resId = R.font.my_font_400_italic,
        weight = FontWeight.W400,
        style = FontStyle.Italic
    )
)
Text(text = "Demo Text", fontFamily = fontFamily)

Properties

fonts

val fonts: List<Font>