# FontsContractCompat

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1  
Summary:[Nested Classes](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat#nestedclasses)\|[Methods](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat#)  

# FontsContractCompat

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
FontsContractCompat
`  
`

extends Object


``


`

|---|-------------------------------------------------|
| java.lang.Object                                   ||
| ↳ | android.support.v4.provider.FontsContractCompat |

<br />

*** ** * ** ***

Utility class to deal with Font ContentProviders.

## Summary

|                                                                                                                                                                                                                        ### Nested classes                                                                                                                                                                                                                        ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [FontsContractCompat.Columns](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.Columns) Defines the constants used in a response from a Font Provider.                                                                                                                                                                                                                                                          |
| ` class` | [FontsContractCompat.FontFamilyResult](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontFamilyResult) Object returned from[fetchFonts(Context, CancellationSignal, FontRequest)](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat#fetchFonts(android.content.Context, android.os.CancellationSignal, android.support.v4.provider.FontRequest)).                      |
| ` class` | [FontsContractCompat.FontInfo](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontInfo) Object represent a font entry in the family returned from[fetchFonts(Context, CancellationSignal, FontRequest)](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat#fetchFonts(android.content.Context, android.os.CancellationSignal, android.support.v4.provider.FontRequest)). |
| ` class` | [FontsContractCompat.FontRequestCallback](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback) Interface used to receive asynchronously fetched typefaces.                                                                                                                                                                                                                                     |

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

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public methods

### buildTypeface

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Build a Typeface from an array of[FontsContractCompat.FontInfo](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.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.html)that will be used to fetch the font contents. <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.html)will be thrown. <br /> |
| `fonts`              | `FontInfo`: An array of[FontsContractCompat.FontInfo](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontInfo)to be used to create a Typeface. <br />                                                                |

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

### fetchFonts

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
FontsContractCompat.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.html)to be used for fetching fonts. <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.html)will be thrown when the query is executed. <br /> |
| `request`            | `FontRequest`: A[FontRequest](https://developer.android.com/reference/android/support/v4/provider/FontRequest)object that identifies the provider and query for the request. <br />                                                                                                      |

|                                                                                                                                                  Returns                                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| [FontsContractCompat.FontFamilyResult](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontFamilyResult) | [FontsContractCompat.FontFamilyResult](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontFamilyResult) <br /> |

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

### requestFont

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void requestFont (Context context, 
                FontRequest request, 
                FontsContractCompat.FontRequestCallback callback, 
                Handler handler)
```

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/support/v4/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.

<br />

|                                                                                                    Parameters                                                                                                    ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context`  | `Context`: A context to be used for fetching from font provider. <br />                                                                                                                              |
| `request`  | `FontRequest`: A[FontRequest](https://developer.android.com/reference/android/support/v4/provider/FontRequest)object that identifies the provider and query for the request. May not be null. <br /> |
| `callback` | `FontsContractCompat.FontRequestCallback`: A callback that will be triggered when results are obtained. May not be null. <br />                                                                      |
| `handler`  | `Handler`: A handler to be processed the font fetching. <br />                                                                                                                                       |

-

  ## Classes

  - [DocumentFile](https://developer.android.com/reference/android/support/v4/provider/DocumentFile)
  - [FontRequest](https://developer.android.com/reference/android/support/v4/provider/FontRequest)
  - [FontsContractCompat](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat)
  - [FontsContractCompat.Columns](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.Columns)
  - [FontsContractCompat.FontFamilyResult](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontFamilyResult)
  - [FontsContractCompat.FontInfo](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontInfo)
  - [FontsContractCompat.FontRequestCallback](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback)