FontsContractCompat
class FontsContractCompat
Utility class to deal with Font ContentProviders.
Summary
Nested types |
|---|
|
Defines the constants used in a response from a Font Provider. |
|
Object returned from |
|
Object represent a font entry in the family returned from |
|
Interface used to receive asynchronously fetched typefaces. |
Public functions |
|
|---|---|
java-static Typeface? |
buildTypeface(Build a Typeface from an array of |
java-static FontsContractCompat.FontFamilyResult |
fetchFonts(Fetch fonts given a font request. |
java-static Unit |
This function is deprecated. due to the non-standard pattern of taking a handler for a non-UI thread - leading to both easily passing an incorrect handler and requiring all callers spin up an extra thread. |
java-static Unit |
requestFont(Request a font async as specified with |
java-static Unit |
requestFontWithFallbackChain(Request a font async as specified with |
Public functions
buildTypeface
java-static fun buildTypeface(
context: Context,
cancellationSignal: CancellationSignal?,
fonts: Array<FontsContractCompat.FontInfo!>
): Typeface?
Build a Typeface from an array of FontInfo Results that are marked as not ready will be skipped.
| Parameters | |
|---|---|
context: Context |
A |
cancellationSignal: CancellationSignal? |
A signal to cancel the operation in progress, or null if none. If the operation is canceled, then |
fonts: Array<FontsContractCompat.FontInfo!> |
An array of |
| Returns | |
|---|---|
Typeface? |
A Typeface object. Returns null if typeface creation fails. |
fetchFonts
java-static fun fetchFonts(
context: Context,
cancellationSignal: CancellationSignal?,
request: FontRequest
): FontsContractCompat.FontFamilyResult
Fetch fonts given a font request.
| Parameters | |
|---|---|
context: Context |
A |
cancellationSignal: CancellationSignal? |
A signal to cancel the operation in progress, or null if none. If the operation is canceled, then |
request: FontRequest |
A |
| Throws | |
|---|---|
android.content.pm.PackageManager.NameNotFoundException |
If requested package or authority was not found in the system. |
java-static funrequestFont(
context: Context,
request: FontRequest,
callback: FontsContractCompat.FontRequestCallback,
handler: Handler
): Unit
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. Only one of the methods in callback will be invoked, depending on whether the request succeeds or fails. These calls will happen on the main thread.
| Parameters | |
|---|---|
context: Context |
A context to be used for fetching from font provider. |
request: FontRequest |
A |
callback: FontsContractCompat.FontRequestCallback |
A callback that will be triggered when results are obtained. May not be null. |
handler: Handler |
A handler for running font fetch tasks on. |
| See also | |
|---|---|
requestFont |
requestFont
java-static fun requestFont(
context: Context,
request: FontRequest,
style: Int,
loadingExecutor: Executor?,
callbackExecutor: Executor,
callback: FontsContractCompat.FontRequestCallback
): Unit
Request a font async as specified with FontRequest Loading may take several seconds, and the loadingExecutor passed should be available to run blocking requests for several seconds. Results will be returned via callbackExecutor.
| Parameters | |
|---|---|
context: Context |
A context to be used for fetching from font provider |
request: FontRequest |
A |
style: Int |
Typeface Style such as |
loadingExecutor: Executor? |
executor to load font on. Loading may take several _seconds_. If |
callbackExecutor: Executor |
Used to dispatch callback |
callback: FontsContractCompat.FontRequestCallback |
A callback that will be triggered when results are obtained. |
requestFontWithFallbackChain
java-static fun requestFontWithFallbackChain(
context: Context,
requests: (Mutable)List<FontRequest!>,
style: Int,
loadingExecutor: Executor?,
callbackExecutor: Executor,
callback: FontsContractCompat.FontRequestCallback
): Unit
Request a font async as specified with FontRequest Loading may take several seconds, and the loadingExecutor passed should be available to run blocking requests for several seconds. Results will be returned via callbackExecutor.
| Parameters | |
|---|---|
context: Context |
A context to be used for fetching from font provider |
requests: (Mutable)List<FontRequest!> |
An array of |
style: Int |
Typeface Style such as |
loadingExecutor: Executor? |
executor to load font on. Loading may take several _seconds_. If |
callbackExecutor: Executor |
Used to dispatch callback |
callback: FontsContractCompat.FontRequestCallback |
A callback that will be triggered when results are obtained. |