requestFont
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
A context to be used for fetching from font provider
A FontRequest object that identifies the provider and query for the request.
Typeface Style such as NORMAL, BOLDITALIC, BOLD_ITALIC.
executor to load font on. Loading may take several _seconds_. If null
, a default executor shared with other null-requests will be used.
Used to dispatch callback
A callback that will be triggered when results are obtained.
Loads a Typeface. Based on the parameters isBlockingFetch, and timeoutInMillis, the fetch is either sync or async. - If timeoutInMillis is infinite, and isBlockingFetch is true -> sync - If timeoutInMillis is NOT infinite, and isBlockingFetch is true -> sync with timeout - else -> async without timeout. Used by TypefaceCompat and tests.
Return
the resulting Typeface if the requested font is in the cache or the request is a sync request.
Parameters
Context
List of FontRequests that define the font to be loaded, followed by any custom fallbacks, in order
Typeface Style such as NORMAL, BOLDITALIC, BOLD_ITALIC.
when true the call will be synchronous.
timeout in milliseconds for the request. It is not used for async request.
the handler to call the callback on.
the callback to be called.
Loads a Typeface. Based on the parameters isBlockingFetch, and timeoutInMillis, the fetch is either sync or async. - If timeoutInMillis is infinite, and isBlockingFetch is true -> sync - If timeoutInMillis is NOT infinite, and isBlockingFetch is true -> sync with timeout - else -> async without timeout. Used by TypefaceCompat and tests.
Return
the resulting Typeface if the requested font is in the cache or the request is a sync request.
Parameters
Context
FontRequest that define the font to be loaded and any fallbacks
Typeface Style such as NORMAL, BOLDITALIC, BOLD_ITALIC.
when true the call will be synchronous.
timeout in milliseconds for the request. It is not used for async request.
the handler to call the callback on.
the callback to be called.
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.
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
A context to be used for fetching from font provider.
A FontRequest object that identifies the provider and query for the request. May not be null.
A callback that will be triggered when results are obtained. May not be null.
A handler to be processed the font fetching.