what-the-bank/sources/o/yHq.java

137 lines
5.3 KiB
Java

package o;
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.airbnb.deeplinkdispatch.base.MatchIndex;
import com.prolificinteractive.materialcalendarview.TitleChanger;
import java.io.IOException;
import java.io.InputStream;
import o.Szw;
import o.ubj;
/* loaded from: classes.dex */
public class yHq extends TMM {
private static int pc_(FontStyle fontStyle, FontStyle fontStyle2) {
return (Math.abs(fontStyle.getWeight() - fontStyle2.getWeight()) / 100) + (fontStyle.getSlant() == fontStyle2.getSlant() ? 0 : 2);
}
private Font pb_(FontFamily fontFamily, int i) {
FontStyle fontStyle = new FontStyle((i & 1) != 0 ? 700 : TitleChanger.DEFAULT_ANIMATION_DELAY, (i & 2) != 0 ? 1 : 0);
Font font = fontFamily.getFont(0);
int pc_ = pc_(fontStyle, font.getStyle());
for (int i2 = 1; i2 < fontFamily.getSize(); i2++) {
Font font2 = fontFamily.getFont(i2);
int pc_2 = pc_(fontStyle, font2.getStyle());
if (pc_2 < pc_) {
font = font2;
pc_ = pc_2;
}
}
return font;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // o.TMM
public ubj.HBt a(ubj.HBt[] hBtArr, int i) {
throw new RuntimeException("Do not use this function in API 29 or later.");
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // o.TMM
public Typeface pl_(Context context, InputStream inputStream) {
throw new RuntimeException("Do not use this function in API 29 or later.");
}
@Override // o.TMM
public Typeface pk_(Context context, CancellationSignal cancellationSignal, ubj.HBt[] hBtArr, int i) {
int i2;
ParcelFileDescriptor openFileDescriptor;
ContentResolver contentResolver = context.getContentResolver();
try {
int length = hBtArr.length;
FontFamily.Builder builder = null;
while (i2 < length) {
ubj.HBt hBt = hBtArr[i2];
try {
openFileDescriptor = contentResolver.openFileDescriptor(hBt.qG_(), MatchIndex.ROOT_VALUE, cancellationSignal);
} catch (IOException unused) {
}
if (openFileDescriptor != null) {
try {
Font build = new Font.Builder(openFileDescriptor).setWeight(hBt.c()).setSlant(hBt.e() ? 1 : 0).setTtcIndex(hBt.b()).build();
if (builder == null) {
builder = new FontFamily.Builder(build);
} else {
builder.addFont(build);
}
if (openFileDescriptor == null) {
}
} catch (Throwable th) {
if (openFileDescriptor != null) {
try {
openFileDescriptor.close();
} catch (Throwable th2) {
th.addSuppressed(th2);
}
}
throw th;
break;
}
} else {
i2 = openFileDescriptor == null ? i2 + 1 : 0;
}
openFileDescriptor.close();
}
if (builder == null) {
return null;
}
FontFamily build2 = builder.build();
return new Typeface.CustomFallbackBuilder(build2).setStyle(pb_(build2, i).getStyle()).build();
} catch (Exception unused2) {
return null;
}
}
@Override // o.TMM
public Typeface pj_(Context context, Szw.IeS ieS, Resources resources, int i) {
try {
FontFamily.Builder builder = null;
for (Szw.LWm lWm : ieS.c()) {
try {
Font build = new Font.Builder(resources, lWm.a()).setWeight(lWm.c()).setSlant(lWm.i() ? 1 : 0).setTtcIndex(lWm.e()).setFontVariationSettings(lWm.b()).build();
if (builder == null) {
builder = new FontFamily.Builder(build);
} else {
builder.addFont(build);
}
} catch (IOException unused) {
}
}
if (builder == null) {
return null;
}
FontFamily build2 = builder.build();
return new Typeface.CustomFallbackBuilder(build2).setStyle(pb_(build2, i).getStyle()).build();
} catch (Exception unused2) {
return null;
}
}
@Override // o.TMM
public Typeface pm_(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;
}
}
}