# FontsContract

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/android/provider/FontsContract#nestedclasses)\|[Methods](https://developer.android.com/reference/android/provider/FontsContract#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/provider/FontsContract#inhmethods)  

# FontsContract

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/provider/FontsContract "View this page in Kotlin")\|Java

`
public


class
FontsContract
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|--------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.provider.FontsContract |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 31.**   
Use the[Jetpack Core Library](https://developer.android.com/jetpack)[FontsContractCompat](https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.html)for consistent behavior across all devices.

Utility class to deal with Font ContentProviders.

## Summary

|                                                                                                                                                                                       ### Nested classes                                                                                                                                                                                       ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [FontsContract.Columns](https://developer.android.com/reference/android/provider/FontsContract.Columns) *This class was deprecated in API level 31. Use the[FontsContractCompat.Columns](https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.Columns.html)for consistent behavior across all devices.*                                                |
| ` class` | [FontsContract.FontFamilyResult](https://developer.android.com/reference/android/provider/FontsContract.FontFamilyResult) *This class was deprecated in API level 31. Use the[FontsContractCompat.FontFamilyResult](https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontFamilyResult.html)for consistent behavior across all devices*             |
| ` class` | [FontsContract.FontInfo](https://developer.android.com/reference/android/provider/FontsContract.FontInfo) *This class was deprecated in API level 31. Use the[FontsContractCompat.FontInfo](https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontInfo.html)for consistent behavior across all devices*                                             |
| ` class` | [FontsContract.FontRequestCallback](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback) *This class was deprecated in API level 31. Use the[FontsContractCompat.FontRequestCallback](https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback.html)for consistent behavior across all devices* |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ||
|-------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[Typeface](https://developer.android.com/reference/android/graphics/Typeface)                                             | ` `[buildTypeface](https://developer.android.com/reference/android/provider/FontsContract#buildTypeface(android.content.Context,%20android.os.CancellationSignal,%20android.provider.FontsContract.FontInfo[]))`(`[Context](https://developer.android.com/reference/android/content/Context)` context, `[CancellationSignal](https://developer.android.com/reference/android/os/CancellationSignal)` cancellationSignal, `[FontInfo[]](https://developer.android.com/reference/android/provider/FontsContract.FontInfo)` fonts) ` Build a Typeface from an array of[FontInfo](https://developer.android.com/reference/android/provider/FontsContract.FontInfo)Results that are marked as not ready will be skipped.                                                                                                                                                |
| ` static `[FontsContract.FontFamilyResult](https://developer.android.com/reference/android/provider/FontsContract.FontFamilyResult) | ` `[fetchFonts](https://developer.android.com/reference/android/provider/FontsContract#fetchFonts(android.content.Context,%20android.os.CancellationSignal,%20android.provider.FontRequest))`(`[Context](https://developer.android.com/reference/android/content/Context)` context, `[CancellationSignal](https://developer.android.com/reference/android/os/CancellationSignal)` cancellationSignal, `[FontRequest](https://developer.android.com/reference/android/provider/FontRequest)` request) ` Fetch fonts given a font request.                                                                                                                                                                                                                                                                                                                           |
| ` static void`                                                                                                                      | ` `[requestFonts](https://developer.android.com/reference/android/provider/FontsContract#requestFonts(android.content.Context,%20android.provider.FontRequest,%20android.os.Handler,%20android.os.CancellationSignal,%20android.provider.FontsContract.FontRequestCallback))`(`[Context](https://developer.android.com/reference/android/content/Context)` context, `[FontRequest](https://developer.android.com/reference/android/provider/FontRequest)` request, `[Handler](https://developer.android.com/reference/android/os/Handler)` handler, `[CancellationSignal](https://developer.android.com/reference/android/os/CancellationSignal)` cancellationSignal, `[FontsContract.FontRequestCallback](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback)` callback) ` Create a typeface object given a font request. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public methods

### buildTypeface

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static Typeface buildTypeface (Context context, 
                CancellationSignal cancellationSignal, 
                FontInfo[] fonts)
```

Build a Typeface from an array of[FontInfo](https://developer.android.com/reference/android/provider/FontsContract.FontInfo)Results that are marked as not ready will be skipped.

<br />

|                                                                                                                                   Parameters                                                                                                                                   ||
|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context`            | `Context`: A[Context](https://developer.android.com/reference/android/content/Context)that will be used to fetch the font contents. This value cannot be`null`. <br />                                                                                   |
| `cancellationSignal` | `CancellationSignal`: A signal to cancel the operation in progress, or null if none. If the operation is canceled, then[OperationCanceledException](https://developer.android.com/reference/android/os/OperationCanceledException)will be thrown. <br /> |
| `fonts`              | `FontInfo`: An array of[FontInfo](https://developer.android.com/reference/android/provider/FontsContract.FontInfo)to be used to create a Typeface. This value cannot be`null`. <br />                                                                    |

|                                                                      Returns                                                                      ||
|-------------------------------------------------------------------------------|--------------------------------------------------------------------|
| [Typeface](https://developer.android.com/reference/android/graphics/Typeface) | A Typeface object. Returns null if typeface creation fails. <br /> |

### fetchFonts

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static FontsContract.FontFamilyResult fetchFonts (Context context, 
                CancellationSignal cancellationSignal, 
                FontRequest request)
```

Fetch fonts given a font request.

<br />

|                                                                                                                                                Parameters                                                                                                                                                 ||
|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context`            | `Context`: A[Context](https://developer.android.com/reference/android/content/Context)to be used for fetching fonts. This value cannot be`null`. <br />                                                                                                                             |
| `cancellationSignal` | `CancellationSignal`: A signal to cancel the operation in progress, or null if none. If the operation is canceled, then[OperationCanceledException](https://developer.android.com/reference/android/os/OperationCanceledException)will be thrown when the query is executed. <br /> |
| `request`            | `FontRequest`: A[FontRequest](https://developer.android.com/reference/android/provider/FontRequest)object that identifies the provider and query for the request. This value cannot be`null`. <br />                                                                                |

|                                                                                                                                 Returns                                                                                                                                  ||
|---------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| [FontsContract.FontFamilyResult](https://developer.android.com/reference/android/provider/FontsContract.FontFamilyResult) | [FontFamilyResult](https://developer.android.com/reference/android/provider/FontsContract.FontFamilyResult)This value cannot be`null`. <br /> |

|                                                                                               Throws                                                                                                ||
|-----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [PackageManager.NameNotFoundException](https://developer.android.com/reference/android/content/pm/PackageManager.NameNotFoundException) | If requested package or authority was not found in system. |

### requestFonts

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void requestFonts (Context context, 
                FontRequest request, 
                Handler handler, 
                CancellationSignal cancellationSignal, 
                FontsContract.FontRequestCallback callback)
```

Create a typeface object given a font request. The font will be asynchronously fetched, therefore the result is delivered to the given callback. See[FontRequest](https://developer.android.com/reference/android/provider/FontRequest). Only one of the methods in callback will be invoked, depending on whether the request succeeds or fails. These calls will happen on the caller thread. Note that the result Typeface may be cached internally and the same instance will be returned the next time you call this method with the same request. If you want to bypass this cache, use[fetchFonts(Context, CancellationSignal, FontRequest)](https://developer.android.com/reference/android/provider/FontsContract#fetchFonts(android.content.Context,%20android.os.CancellationSignal,%20android.provider.FontRequest))and[buildTypeface(Context, CancellationSignal, FontInfo)](https://developer.android.com/reference/android/provider/FontsContract#buildTypeface(android.content.Context,%20android.os.CancellationSignal,%20android.provider.FontsContract.FontInfo[]))instead.

<br />

|                                                                                                                                   Parameters                                                                                                                                   ||
|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context`            | `Context`: A context to be used for fetching from font provider. This value cannot be`null`. <br />                                                                                                                                                      |
| `request`            | `FontRequest`: A[FontRequest](https://developer.android.com/reference/android/provider/FontRequest)object that identifies the provider and query for the request. May not be null. <br />                                                                |
| `handler`            | `Handler`: A handler to be processed the font fetching. This value cannot be`null`. <br />                                                                                                                                                               |
| `cancellationSignal` | `CancellationSignal`: A signal to cancel the operation in progress, or null if none. If the operation is canceled, then[OperationCanceledException](https://developer.android.com/reference/android/os/OperationCanceledException)will be thrown. <br /> |
| `callback`           | `FontsContract.FontRequestCallback`: A callback that will be triggered when results are obtained. May not be null. <br />                                                                                                                                |