package o;

import android.graphics.Paint;
import android.text.style.LineHeightSpan;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.oL, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2042oL implements LineHeightSpan {
    public final float l;
    public final int m;
    public final boolean n;

    /* renamed from: o, reason: collision with root package name */
    public final boolean f661o;
    public final float p;
    public final boolean q;
    public int r = Integer.MIN_VALUE;
    public int s = Integer.MIN_VALUE;
    public int t = Integer.MIN_VALUE;
    public int u = Integer.MIN_VALUE;
    public int v;
    public int w;

    public C2042oL(float f, int i, boolean z, boolean z2, float f2, boolean z3) {
        this.l = f;
        this.m = i;
        this.n = z;
        this.f661o = z2;
        this.p = f2;
        this.q = z3;
        if ((0.0f > f2 || f2 > 1.0f) && f2 != -1.0f) {
            AbstractC2228qH.b("topRatio should be in [0..1] range or -1");
        }
    }

    @Override // android.text.style.LineHeightSpan
    public final void chooseHeight(CharSequence charSequence, int i, int i2, int i3, int i4, Paint.FontMetricsInt fontMetricsInt) {
        int i5 = fontMetricsInt.descent;
        int i6 = fontMetricsInt.ascent;
        if (i5 - i6 <= 0) {
            return;
        }
        boolean z = i == 0;
        boolean z2 = i2 == this.m;
        boolean z3 = this.f661o;
        boolean z4 = this.n;
        if (z && z2 && z4 && z3) {
            return;
        }
        if (this.r == Integer.MIN_VALUE) {
            int i7 = i5 - i6;
            int iCeil = (int) Math.ceil(this.l);
            int i8 = iCeil - i7;
            if (!this.q || i8 > 0) {
                float fAbs = this.p;
                if (fAbs == -1.0f) {
                    fAbs = Math.abs(fontMetricsInt.ascent) / (fontMetricsInt.descent - fontMetricsInt.ascent);
                }
                int iCeil2 = (int) (i8 <= 0 ? Math.ceil(i8 * fAbs) : Math.ceil((1.0f - fAbs) * i8));
                int i9 = fontMetricsInt.descent;
                int i10 = iCeil2 + i9;
                this.t = i10;
                int i11 = i10 - iCeil;
                this.s = i11;
                if (z4) {
                    i11 = fontMetricsInt.ascent;
                }
                this.r = i11;
                if (z3) {
                    i10 = i9;
                }
                this.u = i10;
                this.v = fontMetricsInt.ascent - i11;
                this.w = i10 - i9;
            } else {
                int i12 = fontMetricsInt.ascent;
                this.s = i12;
                int i13 = fontMetricsInt.descent;
                this.t = i13;
                this.r = i12;
                this.u = i13;
                this.v = 0;
                this.w = 0;
            }
        }
        fontMetricsInt.ascent = z ? this.r : this.s;
        fontMetricsInt.descent = z2 ? this.u : this.t;
    }
}
