use of androidx.core.content.res.FontResourcesParserCompat.ProviderResourceEntry in project Carbon by ZieIony.
the class TypefaceCompat method createFromResourcesFamilyXml.
/**
* Create Typeface from XML resource which root node is font-family.
*
* @return null if failed to create.
* @hide
*/
@Nullable
@RestrictTo(LIBRARY_GROUP_PREFIX)
public static Typeface createFromResourcesFamilyXml(@NonNull Context context, @NonNull FamilyResourceEntry entry, @NonNull Resources resources, int id, int style, int weight, @Nullable ResourcesCompat.FontCallback fontCallback, @Nullable Handler handler, boolean isRequestFromLayoutInflator) {
Typeface typeface;
if (entry instanceof ProviderResourceEntry) {
ProviderResourceEntry providerEntry = (ProviderResourceEntry) entry;
final boolean isBlocking = isRequestFromLayoutInflator ? providerEntry.getFetchStrategy() == FontResourcesParserCompat.FETCH_STRATEGY_BLOCKING : fontCallback == null;
final int timeout = isRequestFromLayoutInflator ? providerEntry.getTimeout() : FontResourcesParserCompat.INFINITE_TIMEOUT_VALUE;
typeface = FontsContractCompat.getFontSync(context, providerEntry.getRequest(), fontCallback, handler, isBlocking, timeout, style);
} else {
typeface = sTypefaceCompatImpl.createFromFontFamilyFilesResourceEntry(context, (FontFamilyFilesResourceEntry) entry, resources, (style & Typeface.ITALIC) != 0, weight);
if (fontCallback != null) {
if (typeface != null) {
fontCallback.callbackSuccessAsync(typeface, handler);
} else {
fontCallback.callbackFailAsync(FontsContractCompat.FontRequestCallback.FAIL_REASON_FONT_LOAD_ERROR, handler);
}
}
}
if (typeface != null) {
sTypefaceCache.put(createResourceUid(resources, id, (style & Typeface.ITALIC) != 0, weight), typeface);
}
return typeface;
}
Aggregations