Package-level declarations

Types

Link copied to clipboard
fun interface FontHttpClient

Minimal HTTP abstraction used by the library to download font files and the Google Fonts directory.

Link copied to clipboard
class GoogleFont(val name: String, val bestEffort: Boolean = true)

A font family available on Google Fonts.

Link copied to clipboard
class GoogleFontException(message: String, cause: Throwable? = null) : Exception

Thrown when a Google Font cannot be resolved or loaded.

Link copied to clipboard

Entry point for configuring the library.

Link copied to clipboard
sealed interface GoogleFontState

Result of an in-progress Google Font load, distinguishing "still loading" from "failed".

Functions

Link copied to clipboard
fun Font(googleFont: GoogleFont, weight: FontWeight = FontWeight.Normal, style: FontStyle = FontStyle.Normal, variationSettings: FontVariation.Settings = FontVariation.Settings(weight, style)): Font

Creates a Font for a Google Font using the default provider (Google Play Services on Android).

fun Font(googleFont: GoogleFont, fontProvider: GoogleFont.Provider, weight: FontWeight = FontWeight.Normal, style: FontStyle = FontStyle.Normal, variationSettings: FontVariation.Settings = FontVariation.Settings()): Font

Creates a Font for a Google Font, mirroring the AndroidX ui-text-google-fonts API.

Link copied to clipboard
fun initializeGoogleFonts(context: ERROR CLASS: Symbol not found for Context)

Initializes the library with an application context.

Link copied to clipboard
fun GoogleFont.Provider.isAvailableOnDevice(context: ERROR CLASS: Symbol not found for Context): Boolean

Checks whether the downloadable-fonts provider is available on this device.

Link copied to clipboard
suspend fun GoogleFont.load(weight: FontWeight = FontWeight.Normal, style: FontStyle = FontStyle.Normal, variationSettings: FontVariation.Settings = FontVariation.Settings(weight, style), fontProvider: GoogleFont.Provider? = null, fallback: Font? = null): Font

Loads this Google Font and returns a resolved Compose Font.

Link copied to clipboard
fun rememberGoogleFont(googleFont: GoogleFont, weight: FontWeight = FontWeight.Normal, style: FontStyle = FontStyle.Normal, variationSettings: FontVariation.Settings = FontVariation.Settings(weight, style), fontProvider: GoogleFont.Provider? = null): GoogleFontState

Loads a Google Font and exposes the full load lifecycle: GoogleFontState.Loading, GoogleFontState.Loaded, and GoogleFontState.Failed.

Link copied to clipboard
fun rememberGoogleFontFamily(googleFont: GoogleFont, weight: FontWeight = FontWeight.Normal, style: FontStyle = FontStyle.Normal, variationSettings: FontVariation.Settings = FontVariation.Settings(weight, style), fontProvider: GoogleFont.Provider? = null, fallback: FontFamily? = null, onError: (GoogleFontException) -> Unit? = null): FontFamily?

Loads a Google Font and returns a FontFamily ready to be used in Text(fontFamily = ...).

Link copied to clipboard
suspend fun GoogleFont.toFontFamily(vararg weights: FontWeight, style: FontStyle = FontStyle.Normal, fontProvider: GoogleFont.Provider? = null, fallback: Font? = null): FontFamily

Loads this Google Font at the given weights and returns a FontFamily with one face per weight, mirroring the FontFamily(Font(gf, W400), Font(gf, W700)) pattern.

Link copied to clipboard
fun GoogleFont.warmUp(weight: FontWeight = FontWeight.Normal, style: FontStyle = FontStyle.Normal, variationSettings: FontVariation.Settings = FontVariation.Settings(weight, style), fontProvider: GoogleFont.Provider? = null)

Starts a background download of this font so that a later load or Font resolution hits the cache, and returns immediately.