package G;

import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.fonts.Font;
import android.graphics.text.PositionedGlyphs;
import android.graphics.text.TextRunShaper;
import android.os.Build;
import android.os.Trace;
import android.util.Log;
import java.lang.reflect.Method;

/* JADX INFO: loaded from: classes.dex */
public abstract class e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final S4.d f766a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final r.i f767b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static Paint f768c;

    static {
        Trace.beginSection(android.support.v4.media.session.b.t("TypefaceCompat static init"));
        int i = Build.VERSION.SDK_INT;
        if (i >= 31) {
            f766a = new k();
        } else if (i >= 29) {
            f766a = new j();
        } else if (i >= 28) {
            f766a = new i();
        } else if (i >= 26) {
            f766a = new h();
        } else {
            Method method = g.f776c;
            if (method == null) {
                Log.w("TypefaceCompatApi24Impl", "Unable to collect necessary private methods.Fallback to legacy implementation.");
            }
            if (method != null) {
                f766a = new g();
            } else {
                f766a = new f();
            }
        }
        f767b = new r.i(16);
        f768c = null;
        Trace.endSection();
    }

    /* JADX WARN: Code restructure failed: missing block: B:43:0x00e4, code lost:
    
        r5 = r11.build();
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public static android.graphics.Typeface a(android.content.Context r16, F.d r17, android.content.res.Resources r18, int r19, java.lang.String r20, int r21, int r22, F.b r23, boolean r24) {
        /*
            Method dump skipped, instruction units count: 650
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: G.e.a(android.content.Context, F.d, android.content.res.Resources, int, java.lang.String, int, int, F.b, boolean):android.graphics.Typeface");
    }

    public static String b(Resources resources, int i, String str, int i5, int i6) {
        return resources.getResourcePackageName(i) + '-' + str + '-' + i5 + '-' + i + '-' + i6;
    }

    public static Typeface c(String str) {
        if (str != null && !str.isEmpty()) {
            Typeface typefaceCreate = Typeface.create(str, 0);
            Typeface typefaceCreate2 = Typeface.create(Typeface.DEFAULT, 0);
            if (typefaceCreate != null && !typefaceCreate.equals(typefaceCreate2)) {
                return typefaceCreate;
            }
        }
        return null;
    }

    public static Font d(Typeface typeface) {
        if (f768c == null) {
            f768c = new Paint();
        }
        f768c.setTextSize(10.0f);
        f768c.setTypeface(typeface);
        PositionedGlyphs positionedGlyphsShapeTextRun = TextRunShaper.shapeTextRun((CharSequence) " ", 0, 1, 0, 1, 0.0f, 0.0f, false, f768c);
        if (positionedGlyphsShapeTextRun.glyphCount() == 0) {
            return null;
        }
        return positionedGlyphsShapeTextRun.getFont(0);
    }
}
