Skip to content

SourceSets

rememberVariableIconFont

Android

kotlin
@Composable
fun rememberVariableIconFont(fontConstructor: FontConstructor, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null): VariableIconFont

Creates a variable IconFont using a FontConstructor.

Parameters

fontConstructor

a function returning a Font object, taking as parameters the weight (FontWeight) and the variation settings (FontVariation.Settings)

weights

the supported weights for the font

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax

kotlin
@Composable
fun rememberVariableIconFont(@FontRes resId: Int, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null): VariableIconFont

Creates a variable IconFont using a resource id.

Parameters

resId

the Android resource identifier of the font (e.g. R.font.my_icon_font)

weights

the supported weights for the font

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax

kotlin
@Composable
fun rememberVariableIconFont(file: File, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null): VariableIconFont

Creates a variable IconFont from a file.

Parameters

file

the font file

weights

the supported weights for the font

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax

kotlin
@RequiresApi(value = 26)
@Composable
fun rememberVariableIconFont(fileDescriptor: ParcelFileDescriptor, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null): VariableIconFont

Creates a variable IconFont using a ParcelFileDescriptor. Requires Android Oreo or higher.

Parameters

fileDescriptor

the file descriptor for the font file

weights

the supported weights for the font

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax

kotlin
@Composable
fun rememberVariableIconFont(path: String, weights: Array<FontWeight>, assetManager: AssetManager = rememberLocalContext().current.resources.assets, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null): VariableIconFont

Creates a variable IconFont from a file in the assets directory.

Parameters

path

the full path starting from the assets directory

weights

the supported weights for the font

assetManager

the Android AssetManager

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax

kotlin
@Composable
actual fun rememberVariableIconFont(fontResource: FontResource, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings, fontFeatureSettings: String?): VariableIconFont

Common

kotlin
@Composable
expect fun rememberVariableIconFont(fontResource: FontResource, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null): VariableIconFont

Creates a variable IconFont using a Compose Multiplatform FontResource.

This function is marked as experimental because its Android implementation is using experimental workarounds:

  • On Android 11 and higher this will shortly create an in-memory file descriptor.

  • On Android 8 and higher this will create a temporary file (this file will be deleted after the font is loaded).

  • On Android 7 and lower this will also create a temporary file, but the variation settings will be ignored.

Parameters

fontResource

the Compose Multiplatform resource ID

weights

the supported weights for the font

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax


Desktop (JVM)

kotlin
@Composable
fun rememberVariableIconFont(resource: String, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null, density: Density = LocalDensity.current): VariableIconFont

Creates a variable IconFont using a resource name.

Parameters

resource

the resource name in classpath

weights

the supported weights for the font

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax

kotlin
@Composable
fun rememberVariableIconFont(file: File, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null, density: Density = LocalDensity.current): VariableIconFont

Creates a variable IconFont from a file.

Parameters

file

the font file

weights

the supported weights for the font

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax


Skiko (Desktop & Web)

kotlin
@Composable
fun rememberVariableIconFont(alias: String, baseTypeface: Typeface, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null, density: Density = LocalDensity.current): VariableIconFont

Creates a variable IconFont using a Skia Typeface.

Parameters

alias

the internal name to differentiate the typeface

baseTypeface

the base Skia SkTypeface that will be cloned for each required variation settings

weights

the supported weights for the font

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax

density

the density of the screen, optionally used to convert density-dependent variation settings to pixels

kotlin
@Composable
fun rememberVariableIconFont(alias: String, data: ByteArray, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null, density: Density = LocalDensity.current): VariableIconFont

Creates a variable IconFont using a byte array with loaded font data.

Parameters

alias

the internal name to differentiate the typeface

data

a byte array with loaded font data

weights

the supported weights for the font

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax

density

the density of the screen, optionally used to convert density-dependent variation settings to pixels

kotlin
@Composable
actual fun rememberVariableIconFont(fontResource: FontResource, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings, fontFeatureSettings: String?): VariableIconFont

Web (JS & WASM)

kotlin
@Composable
fun rememberVariableIconFont(resource: Any?, weights: Array<FontWeight>, fontVariationSettings: FontVariation.Settings = FontVariation.Settings(), fontFeatureSettings: String? = null, density: Density = LocalDensity.current): VariableIconFont

Creates a variable IconFont using the path of a font.

Parameters

resource

fetch path of the font file as seen here

weights

supported weights for the font

fontVariationSettings

the font variation settings, should not include the optical size ('opsz') and must not include the weight ('wght')

fontFeatureSettings

the font feature settings, written in a CSS syntax