# GoogleFont

# GoogleFont

Artifact: [androidx.compose.ui:ui-text-google-fonts](https://developer.android.com/jetpack/androidx/releases/compose-ui)  
[View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/googlefonts/GoogleFont.kt+class:androidx.compose.ui.text.googlefonts.GoogleFont)  
Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)


```
class GoogleFont
```

<br />

*** ** * ** ***

A downloadable font from fonts.google.com

To learn more about the features supported by Google Fonts, see [Get Started with the Google Fonts for Android](https://developers.google.com/fonts/docs/android)

For a full list of fonts available on Android, see the [Google Fonts Directory For Android XML](https://fonts.gstatic.com/s/a/directory.xml).  

|                                                             Throws                                                             |
|--------------------------------------------------------------------------------------------------------------------------------|------------------|
| [kotlin.IllegalArgumentException](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html) | if name is empty |

## Summary

|                                                                                                                                                                                                                                    ### Nested types                                                                                                                                                                                                                                     |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[GoogleFont.Provider](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/googlefonts/GoogleFont.Provider) Attributes used to create a [FontRequest](https://developer.android.com/reference/kotlin/androidx/core/provider/FontRequest) for a [GoogleFont](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/googlefonts/GoogleFont) based [Font](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font). |

|                                                                                                                                                                ### Public constructors                                                                                                                                                                |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [GoogleFont](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/googlefonts/GoogleFont#GoogleFont(kotlin.String,kotlin.Boolean))`(name: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`, bestEffort: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` |

|                                ### Public properties                                |
|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [bestEffort](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/googlefonts/GoogleFont#bestEffort()) If besteffort is true and your query specifies a valid family name but the requested width/weight/italic value is not supported Google Fonts will return the best match it can find within the family. |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)   | [name](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/googlefonts/GoogleFont#name()) Name of a font on Google fonts, such as "Roboto" or "Open Sans"                                                                                                                                                    |

## Public constructors

### GoogleFont

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)  

```
GoogleFont(name: String, bestEffort: Boolean = true)
```  

|                                                 Parameters                                                 |
|------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                  | Name of a font on Google fonts, such as "Roboto" or "Open Sans"                                                                                                                                                                                       |
| `bestEffort: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` = true` | If besteffort is true and your query specifies a valid family name but the requested width/weight/italic value is not supported Google Fonts will return the best match it can find within the family. If false, exact matches will be returned only. |

## Public properties

### bestEffort

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)  

```
val bestEffort: Boolean
```

If besteffort is true and your query specifies a valid family name but the requested width/weight/italic value is not supported Google Fonts will return the best match it can find within the family. If false, exact matches will be returned only.  

### name

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)  

```
val name: String
```

Name of a font on Google fonts, such as "Roboto" or "Open Sans"