alexandroid/decompiled/jadx/sources/com/facebook/react/common/assets/ReactFontManager.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

215 lines
14 KiB
Java

package com.facebook.react.common.assets;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.util.SparseArray;
import androidx.core.content.res.ResourcesCompat;
import defpackage.a$$ExternalSyntheticOutline0;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.Metadata;
import kotlin.jvm.JvmOverloads;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.SourceDebugExtension;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Metadata(d1 = {"\u0000J\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010%\n\u0002\u0010\u000e\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\u0018\u0000 \u001f2\u00020\u0001:\u0003\u001e\u001f B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J \u0010\n\u001a\u00020\t2\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\f\u001a\u00020\r2\b\u0010\u000e\u001a\u0004\u0018\u00010\u000fJ(\u0010\n\u001a\u00020\t2\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\u0010\u001a\u00020\r2\u0006\u0010\u0011\u001a\u00020\u00122\b\u0010\u000e\u001a\u0004\u0018\u00010\u000fJ(\u0010\n\u001a\u00020\t2\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\f\u001a\u00020\r2\u0006\u0010\u0010\u001a\u00020\r2\b\u0010\u000e\u001a\u0004\u0018\u00010\u000fJ \u0010\n\u001a\u00020\t2\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\u0013\u001a\u00020\u00142\b\u0010\u000e\u001a\u0004\u0018\u00010\u000fJ\u001e\u0010\u0015\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u00062\u0006\u0010\u001a\u001a\u00020\rJ\u0018\u0010\u0015\u001a\u00020\u00162\u0006\u0010\u0019\u001a\u00020\u00062\b\u0010\u001b\u001a\u0004\u0018\u00010\tJ \u0010\u001c\u001a\u00020\u00162\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\f\u001a\u00020\r2\b\u0010\u001d\u001a\u0004\u0018\u00010\tR\u001a\u0010\u0004\u001a\u000e\u0012\u0004\u0012\u00020\u0006\u0012\u0004\u0012\u00020\u00070\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u001a\u0010\b\u001a\u000e\u0012\u0004\u0012\u00020\u0006\u0012\u0004\u0012\u00020\t0\u0005X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006!"}, d2 = {"Lcom/facebook/react/common/assets/ReactFontManager;", "", "<init>", "()V", "fontCache", "", "", "Lcom/facebook/react/common/assets/ReactFontManager$AssetFontFamily;", "customTypefaceCache", "Landroid/graphics/Typeface;", "getTypeface", "fontFamilyName", "style", "", "assetManager", "Landroid/content/res/AssetManager;", "weight", "italic", "", "typefaceStyle", "Lcom/facebook/react/common/assets/ReactFontManager$TypefaceStyle;", "addCustomFont", "", "context", "Landroid/content/Context;", "fontFamily", "fontId", "font", "setTypeface", "typeface", "TypefaceStyle", "Companion", "AssetFontFamily", "ReactAndroid_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
@SourceDebugExtension({"SMAP\nReactFontManager.kt\nKotlin\n*S Kotlin\n*F\n+ 1 ReactFontManager.kt\ncom/facebook/react/common/assets/ReactFontManager\n+ 2 Maps.kt\nkotlin/collections/MapsKt__MapsKt\n*L\n1#1,198:1\n384#2,7:199\n384#2,7:206\n*S KotlinDebug\n*F\n+ 1 ReactFontManager.kt\ncom/facebook/react/common/assets/ReactFontManager\n*L\n67#1:199,7\n106#1:206,7\n*E\n"})
/* loaded from: classes6.dex */
public final class ReactFontManager {
@NotNull
private static final String FONTS_ASSET_PATH = "fonts/";
/* renamed from: Companion, reason: from kotlin metadata */
@NotNull
public static final Companion INSTANCE = new Companion(null);
@NotNull
private static final String[] EXTENSIONS = {"", "_bold", "_italic", "_bold_italic"};
@NotNull
private static final String[] FILE_EXTENSIONS = {".ttf", ".otf"};
@NotNull
private static final ReactFontManager _instance = new ReactFontManager();
@NotNull
private final Map<String, AssetFontFamily> fontCache = new LinkedHashMap();
@NotNull
private final Map<String, Typeface> customTypefaceCache = new LinkedHashMap();
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\b\u0002\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\u0010\u0010\u0007\u001a\u0004\u0018\u00010\u00062\u0006\u0010\b\u001a\u00020\tJ\u0018\u0010\n\u001a\u00020\u000b2\u0006\u0010\b\u001a\u00020\t2\b\u0010\f\u001a\u0004\u0018\u00010\u0006R\u0016\u0010\u0004\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00060\u0005X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\r"}, d2 = {"Lcom/facebook/react/common/assets/ReactFontManager$AssetFontFamily;", "", "<init>", "()V", "typefaceSparseArray", "Landroid/util/SparseArray;", "Landroid/graphics/Typeface;", "getTypefaceForStyle", "style", "", "setTypefaceForStyle", "", "typeface", "ReactAndroid_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
public static final class AssetFontFamily {
@NotNull
private final SparseArray<Typeface> typefaceSparseArray = new SparseArray<>(4);
@Nullable
public final Typeface getTypefaceForStyle(int style) {
return this.typefaceSparseArray.get(style);
}
public final void setTypefaceForStyle(int style, @Nullable Typeface typeface) {
this.typefaceSparseArray.put(style, typeface);
}
}
@JvmStatic
@NotNull
public static final ReactFontManager getInstance() {
return INSTANCE.getInstance();
}
public final void addCustomFont(@NotNull Context context, @NotNull String fontFamily, int fontId) {
context.getClass();
fontFamily.getClass();
addCustomFont(fontFamily, ResourcesCompat.getFont(context, fontId));
}
@NotNull
public final Typeface getTypeface(@NotNull String fontFamilyName, @NotNull TypefaceStyle typefaceStyle, @Nullable AssetManager assetManager) {
fontFamilyName.getClass();
typefaceStyle.getClass();
if (this.customTypefaceCache.containsKey(fontFamilyName)) {
return typefaceStyle.apply(this.customTypefaceCache.get(fontFamilyName));
}
Map<String, AssetFontFamily> map = this.fontCache;
AssetFontFamily assetFontFamily = map.get(fontFamilyName);
if (assetFontFamily == null) {
assetFontFamily = new AssetFontFamily();
map.put(fontFamilyName, assetFontFamily);
}
AssetFontFamily assetFontFamily2 = assetFontFamily;
int nearestStyle = typefaceStyle.getNearestStyle();
Typeface typefaceForStyle = assetFontFamily2.getTypefaceForStyle(nearestStyle);
if (typefaceForStyle != null) {
return typefaceForStyle;
}
Typeface createAssetTypeface = INSTANCE.createAssetTypeface(fontFamilyName, nearestStyle, assetManager);
assetFontFamily2.setTypefaceForStyle(nearestStyle, createAssetTypeface);
return createAssetTypeface;
}
public final void setTypeface(@NotNull String fontFamilyName, int style, @Nullable Typeface typeface) {
fontFamilyName.getClass();
if (typeface != null) {
Map<String, AssetFontFamily> map = this.fontCache;
AssetFontFamily assetFontFamily = map.get(fontFamilyName);
if (assetFontFamily == null) {
assetFontFamily = new AssetFontFamily();
map.put(fontFamilyName, assetFontFamily);
}
assetFontFamily.setTypefaceForStyle(style, typeface);
}
}
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Metadata(d1 = {"\u00004\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\b\u0010\f\u001a\u00020\u000bH\u0007J\"\u0010\r\u001a\u00020\u000e2\u0006\u0010\u000f\u001a\u00020\u00062\u0006\u0010\u0010\u001a\u00020\u00112\b\u0010\u0012\u001a\u0004\u0018\u00010\u0013H\u0002R\u0016\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00060\u0005X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u0007R\u0016\u0010\b\u001a\b\u0012\u0004\u0012\u00020\u00060\u0005X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u0007R\u000e\u0010\t\u001a\u00020\u0006X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0014"}, d2 = {"Lcom/facebook/react/common/assets/ReactFontManager$Companion;", "", "<init>", "()V", "EXTENSIONS", "", "", "[Ljava/lang/String;", "FILE_EXTENSIONS", "FONTS_ASSET_PATH", "_instance", "Lcom/facebook/react/common/assets/ReactFontManager;", "getInstance", "createAssetTypeface", "Landroid/graphics/Typeface;", "fontFamilyName", "style", "", "assetManager", "Landroid/content/res/AssetManager;", "ReactAndroid_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
/* JADX INFO: Access modifiers changed from: private */
public final Typeface createAssetTypeface(String fontFamilyName, int style, AssetManager assetManager) {
if (assetManager != null) {
String str = ReactFontManager.EXTENSIONS[style];
for (String str2 : ReactFontManager.FILE_EXTENSIONS) {
try {
Typeface createFromAsset = Typeface.createFromAsset(assetManager, a$$ExternalSyntheticOutline0.m(ReactFontManager.FONTS_ASSET_PATH, fontFamilyName, str, str2));
createFromAsset.getClass();
return createFromAsset;
} catch (RuntimeException unused) {
}
}
}
Typeface create = Typeface.create(fontFamilyName, style);
create.getClass();
return create;
}
@JvmStatic
@NotNull
public final ReactFontManager getInstance() {
return ReactFontManager._instance;
}
private Companion() {
}
}
public final void addCustomFont(@NotNull String fontFamily, @Nullable Typeface font) {
fontFamily.getClass();
if (font != null) {
this.customTypefaceCache.put(fontFamily, font);
}
}
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000b\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0003\u0018\u0000 \u00102\u00020\u0001:\u0001\u0010B\u0019\b\u0016\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0004\b\u0006\u0010\u0007B\u001b\b\u0017\u0012\u0006\u0010\b\u001a\u00020\u0003\u0012\b\b\u0002\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0006\u0010\tJ\u0010\u0010\r\u001a\u00020\u000e2\b\u0010\u000f\u001a\u0004\u0018\u00010\u000eR\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010\n\u001a\u00020\u00038F¢\u0006\u0006\u001a\u0004\b\u000b\u0010\f¨\u0006\u0011"}, d2 = {"Lcom/facebook/react/common/assets/ReactFontManager$TypefaceStyle;", "", "weight", "", "italic", "", "<init>", "(IZ)V", "style", "(II)V", "nearestStyle", "getNearestStyle", "()I", "apply", "Landroid/graphics/Typeface;", "typeface", "Companion", "ReactAndroid_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
public static final class TypefaceStyle {
public static final int BOLD = 700;
public static final int NORMAL = 400;
private final boolean italic;
private final int weight;
@JvmOverloads
public TypefaceStyle(int i, int i2) {
i = i == -1 ? 0 : i;
this.italic = (i & 2) != 0;
this.weight = i2 == -1 ? (i & 1) != 0 ? 700 : 400 : i2;
}
@NotNull
public final Typeface apply(@Nullable Typeface typeface) {
Typeface create = Typeface.create(typeface, this.weight, this.italic);
create.getClass();
return create;
}
public final int getNearestStyle() {
int i = this.weight;
boolean z = this.italic;
return i < 700 ? z ? 2 : 0 : z ? 3 : 1;
}
public TypefaceStyle(int i, boolean z) {
this.italic = z;
this.weight = i == -1 ? 400 : i;
}
public /* synthetic */ TypefaceStyle(int i, int i2, int i3, DefaultConstructorMarker defaultConstructorMarker) {
this(i, (i3 & 2) != 0 ? -1 : i2);
}
@JvmOverloads
public TypefaceStyle(int i) {
this(i, 0, 2, null);
}
}
@NotNull
public final Typeface getTypeface(@NotNull String fontFamilyName, int weight, boolean italic, @Nullable AssetManager assetManager) {
fontFamilyName.getClass();
return getTypeface(fontFamilyName, new TypefaceStyle(weight, italic), assetManager);
}
@NotNull
public final Typeface getTypeface(@NotNull String fontFamilyName, int style, int weight, @Nullable AssetManager assetManager) {
fontFamilyName.getClass();
return getTypeface(fontFamilyName, new TypefaceStyle(style, weight), assetManager);
}
@NotNull
public final Typeface getTypeface(@NotNull String fontFamilyName, int style, @Nullable AssetManager assetManager) {
fontFamilyName.getClass();
return getTypeface(fontFamilyName, new TypefaceStyle(style, 0, 2, null), assetManager);
}
}