You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
7.2 KiB

package p073z;
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 java.io.IOException;
import java.io.InputStream;
import p014e0.C0655g;
import p071y.C1812f;
/* renamed from: z.n0 */
/* loaded from: classes.dex */
public class C1897n0 extends C1899o0 {
/* renamed from: m */
public static int m97m(FontStyle fontStyle, FontStyle fontStyle2) {
int weight;
int weight2;
int slant;
int slant2;
weight = fontStyle.getWeight();
weight2 = fontStyle2.getWeight();
int abs = Math.abs(weight - weight2) / 100;
slant = fontStyle.getSlant();
slant2 = fontStyle2.getSlant();
return abs + (slant == slant2 ? 0 : 2);
}
@Override // p073z.C1899o0
/* renamed from: b */
public Typeface mo55b(Context context, C1812f.C1815c c1815c, Resources resources, int i) {
C1812f.C1816d[] m309a;
FontFamily build;
FontStyle style;
Typeface.CustomFallbackBuilder style2;
Typeface build2;
Font.Builder weight;
Font.Builder slant;
Font.Builder ttcIndex;
Font.Builder fontVariationSettings;
Font build3;
try {
FontFamily.Builder builder = null;
for (C1812f.C1816d c1816d : c1815c.m309a()) {
try {
weight = new Font.Builder(resources, c1816d.m307b()).setWeight(c1816d.m304e());
slant = weight.setSlant(c1816d.m303f() ? 1 : 0);
ttcIndex = slant.setTtcIndex(c1816d.m306c());
fontVariationSettings = ttcIndex.setFontVariationSettings(c1816d.m305d());
build3 = fontVariationSettings.build();
if (builder == null) {
builder = new FontFamily.Builder(build3);
} else {
builder.addFont(build3);
}
} catch (IOException unused) {
}
}
if (builder == null) {
return null;
}
build = builder.build();
Typeface.CustomFallbackBuilder customFallbackBuilder = new Typeface.CustomFallbackBuilder(build);
style = m98l(build, i).getStyle();
style2 = customFallbackBuilder.setStyle(style);
build2 = style2.build();
return build2;
} catch (Exception unused2) {
return null;
}
}
@Override // p073z.C1899o0
/* renamed from: c */
public Typeface mo54c(Context context, CancellationSignal cancellationSignal, C0655g.C0657b[] c0657bArr, int i) {
int i2;
FontFamily build;
FontStyle style;
Typeface.CustomFallbackBuilder style2;
Typeface build2;
ParcelFileDescriptor openFileDescriptor;
Font.Builder weight;
Font.Builder slant;
Font.Builder ttcIndex;
Font build3;
ContentResolver contentResolver = context.getContentResolver();
try {
int length = c0657bArr.length;
FontFamily.Builder builder = null;
while (i2 < length) {
C0655g.C0657b c0657b = c0657bArr[i2];
try {
openFileDescriptor = contentResolver.openFileDescriptor(c0657b.m3189d(), "r", cancellationSignal);
} catch (IOException unused) {
}
if (openFileDescriptor != null) {
try {
weight = new Font.Builder(openFileDescriptor).setWeight(c0657b.m3188e());
slant = weight.setSlant(c0657b.m3187f() ? 1 : 0);
ttcIndex = slant.setTtcIndex(c0657b.m3190c());
build3 = ttcIndex.build();
if (builder == null) {
builder = new FontFamily.Builder(build3);
} else {
builder.addFont(build3);
}
} catch (Throwable th) {
try {
openFileDescriptor.close();
} catch (Throwable th2) {
Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class).invoke(th, th2);
}
throw th;
break;
}
} else {
i2 = openFileDescriptor == null ? i2 + 1 : 0;
}
openFileDescriptor.close();
}
if (builder == null) {
return null;
}
build = builder.build();
Typeface.CustomFallbackBuilder customFallbackBuilder = new Typeface.CustomFallbackBuilder(build);
style = m98l(build, i).getStyle();
style2 = customFallbackBuilder.setStyle(style);
build2 = style2.build();
return build2;
} catch (Exception unused2) {
return null;
}
}
@Override // p073z.C1899o0
/* renamed from: d */
public Typeface mo94d(Context context, InputStream inputStream) {
throw new RuntimeException("Do not use this function in API 29 or later.");
}
@Override // p073z.C1899o0
/* renamed from: e */
public Typeface mo53e(Context context, Resources resources, int i, String str, int i2) {
Font build;
FontFamily build2;
FontStyle style;
Typeface.CustomFallbackBuilder style2;
Typeface build3;
try {
build = new Font.Builder(resources, i).build();
build2 = new FontFamily.Builder(build).build();
Typeface.CustomFallbackBuilder customFallbackBuilder = new Typeface.CustomFallbackBuilder(build2);
style = build.getStyle();
style2 = customFallbackBuilder.setStyle(style);
build3 = style2.build();
return build3;
} catch (Exception unused) {
return null;
}
}
@Override // p073z.C1899o0
/* renamed from: i */
public C0655g.C0657b mo90i(C0655g.C0657b[] c0657bArr, int i) {
throw new RuntimeException("Do not use this function in API 29 or later.");
}
/* JADX WARN: Incorrect condition in loop: B:12:0x0027 */
/* renamed from: l */
/*
Code decompiled incorrectly, please refer to instructions dump.
*/
public final Font m98l(FontFamily fontFamily, int i) {
Font font;
FontStyle style;
int size;
Font font2;
FontStyle style2;
FontStyle fontStyle = new FontStyle((i & 1) != 0 ? 700 : 400, (i & 2) != 0 ? 1 : 0);
font = fontFamily.getFont(0);
style = font.getStyle();
int m97m = m97m(fontStyle, style);
for (int i2 = 1; i2 < size; i2++) {
font2 = fontFamily.getFont(i2);
style2 = font2.getStyle();
int m97m2 = m97m(fontStyle, style2);
if (m97m2 < m97m) {
font = font2;
m97m = m97m2;
}
}
return font;
}
}