Remote Compose Storybook English GitHub

RemoteText · Font families

The generic families a player resolves to its own fonts.

RemoteText · Font families: документ, нарисованный плеером Remote Compose
Открыть живое интерактивное демо →

Меняйте параметры, смотрите удалённый документ, который получается, и разницу после каждого изменения.

Что это

Показывает текст с нужным размером, цветом, начертанием, шрифтом, выравниванием и ограничением строк; если не помещается — заканчивается «…».

Подходит для

  • Заголовки, подписи, абзацы
  • Цены и статусы, которые обновляет сервер

Код

Исходник примера с импортами androidx.compose.remote. CI компилирует каждый фрагмент кода на сайте против AndroidX.

import androidx.compose.remote.creation.compose.layout.RemoteArrangement
import androidx.compose.remote.creation.compose.layout.RemoteColumn
import androidx.compose.remote.creation.compose.layout.RemoteComposable
import androidx.compose.remote.creation.compose.layout.RemoteText
import androidx.compose.remote.creation.compose.state.rdp
import androidx.compose.remote.creation.compose.state.rs
import androidx.compose.remote.creation.compose.state.rsp
import androidx.compose.remote.creation.compose.text.RemoteFontFamily
import androidx.compose.runtime.Composable

@Composable
@RemoteComposable
fun TextFontFamilies(sample: String, fontSize: Int) {
    RemoteColumn(verticalArrangement = RemoteArrangement.spacedBy(6.rdp)) {
        RemoteText(
            "Default: $sample".rs,
            fontFamily = RemoteFontFamily.Default,
            fontSize = fontSize.rsp,
        )
        RemoteText(
            "SansSerif: $sample".rs,
            fontFamily = RemoteFontFamily.SansSerif,
            fontSize = fontSize.rsp,
        )
        RemoteText(
            "Serif: $sample".rs,
            fontFamily = RemoteFontFamily.Serif,
            fontSize = fontSize.rsp,
        )
        RemoteText(
            "Monospace: $sample".rs,
            fontFamily = RemoteFontFamily.Monospace,
            fontSize = fontSize.rsp,
        )
        RemoteText(
            "Cursive: $sample".rs,
            fontFamily = RemoteFontFamily.Cursive,
            fontSize = fontSize.rsp,
        )
    }
}

API

creation.compose.layout.RemoteText

void RemoteText(RemoteString text, optional RemoteModifier modifier, optional RemoteColor? color, optional RemoteTextUnit? fontSize, optional RemoteFontStyle? fontStyle, optional RemoteFontWeight? fontWeight, optional RemoteFontFamily? fontFamily, optional RemoteTextAlign? textAlign, optional RemoteTextOverflow overflow, optional int maxLines, optional String? fontFeatureSettings, optional RemoteFontVariation.Settings? fontVariationSettings, optional RemoteTextStyle style)

creation.compose.text.RemoteTextStyle

class RemoteTextStyle
  RemoteTextStyle(optional RemoteColor? color, optional RemoteTextUnit? fontSize, optional RemoteFontWeight? fontWeight, optional RemoteFontStyle? fontStyle, optional RemoteFontFamily? fontFamily, optional RemoteTextUnit? letterSpacing, optional RemoteColor? background, optional RemoteTextAlign textAlign, optional RemoteTextUnit? lineHeight, optional RemoteTextDecoration? textDecoration, optional RemoteLineBreak lineBreak, optional RemoteHyphens hyphens, optional String? fontFeatureSettings, optional RemoteFontVariation.Settings? fontVariationSettings)
  RemoteTextStyle copy(optional RemoteColor? color, optional RemoteTextUnit? fontSize, optional RemoteFontWeight? fontWeight, optional RemoteFontStyle? fontStyle, optional RemoteFontFamily? fontFamily, optional RemoteTextUnit? letterSpacing, optional RemoteColor? background, optional RemoteTextAlign textAlign, optional RemoteTextUnit? lineHeight, optional RemoteTextDecoration? textDecoration, optional RemoteLineBreak lineBreak, optional RemoteHyphens hyphens, optional String? fontFeatureSettings, optional RemoteFontVariation.Settings? fontVariationSettings)
  RemoteTextStyle merge(optional RemoteColor? color, optional RemoteTextUnit? fontSize, optional RemoteFontWeight? fontWeight, optional RemoteFontStyle? fontStyle, optional RemoteFontFamily? fontFamily, optional RemoteTextUnit? letterSpacing, optional RemoteColor? background, optional RemoteTextAlign textAlign, optional RemoteTextUnit? lineHeight, optional RemoteTextDecoration? textDecoration, optional RemoteLineBreak lineBreak, optional RemoteHyphens hyphens, optional String? fontFeatureSettings, optional RemoteFontVariation.Settings? fontVariationSettings)
  RemoteTextStyle merge(RemoteTextStyle? other)
  RemoteColor? background
  RemoteColor? color
  RemoteFontFamily? fontFamily
  String? fontFeatureSettings
  RemoteTextUnit? fontSize
  RemoteFontStyle? fontStyle
  RemoteFontVariation.Settings? fontVariationSettings
  RemoteFontWeight? fontWeight
  RemoteHyphens hyphens
  RemoteTextUnit? letterSpacing
  RemoteLineBreak lineBreak
  RemoteTextUnit? lineHeight
  RemoteTextAlign textAlign
  RemoteTextDecoration? textDecoration
  RemoteTextStyle.Companion Companion
  RemoteTextStyle Default

creation.compose.text.RemoteFontWeight

class RemoteFontWeight
  RemoteFontWeight(RemoteFloat weight)
  RemoteFontWeight(int weight)
  RemoteFloat weight
  RemoteFontWeight.Companion Companion
  RemoteFontWeight Black
  RemoteFontWeight Bold
  RemoteFontWeight ExtraBold
  RemoteFontWeight ExtraLight
  RemoteFontWeight Light
  RemoteFontWeight Medium
  RemoteFontWeight Normal
  RemoteFontWeight SemiBold
  RemoteFontWeight Thin
  RemoteFontWeight W100
  RemoteFontWeight W200
  RemoteFontWeight W300
  RemoteFontWeight W400
  RemoteFontWeight W500
  RemoteFontWeight W600
  RemoteFontWeight W700
  RemoteFontWeight W800
  RemoteFontWeight W900

creation.compose.text.RemoteFontFamily

sealed exhaustive class RemoteFontFamily
  String name
  RemoteFontFamily.Cursive INSTANCE
  RemoteFontFamily.Default INSTANCE
  RemoteFontFamily.Monospace INSTANCE
  RemoteFontFamily.Named(String name)
  RemoteFontFamily.SansSerif INSTANCE
  RemoteFontFamily.Serif INSTANCE

Справочник

Другие примеры этого компонента

Ещё в разделе «Контент»