package ῲ.ᨨ.ʬ;

import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.graphics.fonts.Font;
import android.graphics.fonts.FontFamily;
import android.graphics.fonts.FontStyle;
import android.os.CancellationSignal;
import android.os.ParcelFileDescriptor;
import com.adjust.sdk.Constants;
import java.io.IOException;
import ῲ.ᨨ.ῲ.ῲ.C1796;
import ῲ.ᨨ.ῲ.ῲ.C1804;
import ῲ.ᨨ.㴹.C1847;

/* renamed from: ῲ.ᨨ.ʬ.ᨨ  reason: contains not printable characters */
/* compiled from: TypefaceCompatApi29Impl */
public class C1715 extends C1719 {
    @Override // ῲ.ᨨ.ʬ.C1719
    /* renamed from: K  reason: contains not printable characters */
    public C1847 m4393(C1847[] r1, int i) {
        throw new RuntimeException("Do not use this function in API 29 or later.");
    }

    @Override // ῲ.ᨨ.ʬ.C1719
    /* renamed from: K  reason: contains not printable characters */
    public Typeface m4391(Context context, CancellationSignal cancellationSignal, C1847[] r13, int i) {
        ContentResolver contentResolver = context.getContentResolver();
        try {
            int length = r13.length;
            int i2 = 0;
            FontFamily.Builder builder = null;
            int i3 = 0;
            while (true) {
                int i4 = 1;
                if (i3 >= length) {
                    break;
                }
                C1847 r6 = r13[i3];
                try {
                    ParcelFileDescriptor openFileDescriptor = contentResolver.openFileDescriptor(r6.f6280, "r", cancellationSignal);
                    if (openFileDescriptor != null) {
                        try {
                            Font.Builder weight = new Font.Builder(openFileDescriptor).setWeight(r6.f6277);
                            if (!r6.f6281) {
                                i4 = 0;
                            }
                            Font build = weight.setSlant(i4).setTtcIndex(r6.f6279).build();
                            if (builder == null) {
                                builder = new FontFamily.Builder(build);
                            } else {
                                builder.addFont(build);
                            }
                        } catch (Throwable th) {
                            th.addSuppressed(th);
                        }
                    } else if (openFileDescriptor == null) {
                        i3++;
                    }
                    openFileDescriptor.close();
                } catch (IOException unused) {
                }
                i3++;
            }
            if (builder == null) {
                return null;
            }
            int i5 = (i & 1) != 0 ? 700 : Constants.MINIMAL_ERROR_STATUS_CODE;
            if ((i & 2) != 0) {
                i2 = 1;
            }
            return new Typeface.CustomFallbackBuilder(builder.build()).setStyle(new FontStyle(i5, i2)).build();
            throw th;
        } catch (Exception unused2) {
            return null;
        }
    }

    @Override // ῲ.ᨨ.ʬ.C1719
    /* renamed from: K  reason: contains not printable characters */
    public Typeface m4390(Context context, Resources resources, int i, String str, int i2) {
        try {
            Font build = new Font.Builder(resources, i).build();
            return new Typeface.CustomFallbackBuilder(new FontFamily.Builder(build).build()).setStyle(build.getStyle()).build();
        } catch (Exception unused) {
            return null;
        }
    }

    @Override // ῲ.ᨨ.ʬ.C1719
    /* renamed from: K  reason: contains not printable characters */
    public Typeface m4392(Context context, C1796 r10, Resources resources, int i) {
        try {
            C1804[] r102 = r10.f6145;
            int length = r102.length;
            int i2 = 0;
            FontFamily.Builder builder = null;
            int i3 = 0;
            while (true) {
                int i4 = 1;
                if (i3 >= length) {
                    break;
                }
                C1804 r5 = r102[i3];
                try {
                    Font.Builder weight = new Font.Builder(resources, r5.f6163).setWeight(r5.f6161);
                    if (!r5.f6159) {
                        i4 = 0;
                    }
                    Font build = weight.setSlant(i4).setTtcIndex(r5.f6160).setFontVariationSettings(r5.f6164).build();
                    if (builder == null) {
                        builder = new FontFamily.Builder(build);
                    } else {
                        builder.addFont(build);
                    }
                } catch (IOException unused) {
                }
                i3++;
            }
            if (builder == null) {
                return null;
            }
            int i5 = (i & 1) != 0 ? 700 : Constants.MINIMAL_ERROR_STATUS_CODE;
            if ((i & 2) != 0) {
                i2 = 1;
            }
            return new Typeface.CustomFallbackBuilder(builder.build()).setStyle(new FontStyle(i5, i2)).build();
        } catch (Exception unused2) {
            return null;
        }
    }
}
