androidx.compose.ui.text.googlefonts
Classes
GoogleFont |
A downloadable font from fonts.google.com |
GoogleFont.Provider |
Attributes used to create a |
Top-level functions summary
Font |
Font(Load a font from Google Fonts via Downloadable Fonts. |
GoogleFont |
GoogleFont(context: Context, fontXml: @FontRes Int)Load a Google Font from XML |
Extension functions summary
Boolean |
Check if the downloadable fonts provider is available on device. |
Top-level functions
Font
fun Font(
googleFont: GoogleFont,
fontProvider: GoogleFont.Provider,
weight: FontWeight = FontWeight.W400,
style: FontStyle = FontStyle.Normal
): Font
Load a font from Google Fonts via Downloadable Fonts.
To learn more about the features supported by Google Fonts, see Get Started with the Google Fonts for Android
| Parameters | |
|---|---|
googleFont: GoogleFont |
A font to load from fonts.google.com |
fontProvider: GoogleFont.Provider |
configuration for downloadable font provider |
weight: FontWeight = FontWeight.W400 |
font weight to load |
style: FontStyle = FontStyle.Normal |
italic or normal font |
GoogleFont
fun GoogleFont(context: Context, fontXml: @FontRes Int): GoogleFont
Load a Google Font from XML
This will load only the name and besteffort parameters.
Compared to the string constructor, this loader adds additional overhead. New code should prefer to use GoogleFont(name: String).
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if the fontRes does not exist or is not an xml GoogleFont |
Extension functions
isAvailableOnDevice
@WorkerThread
fun GoogleFont.Provider.isAvailableOnDevice(context: Context): Boolean
Check if the downloadable fonts provider is available on device.
This is not necessary for normal usage, but may be useful in debugging downloadable fonts behavior.
| Parameters | |
|---|---|
context: Context |
for looking up font provider in |
| Returns | |
|---|---|
Boolean |
true if the provider is usable for downloadable fonts, false if it's not found |
| Throws | |
|---|---|
kotlin.IllegalStateException |
if the provider is on device, but certificates don't match |