package W0;

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

/* JADX INFO: loaded from: classes.dex */
public final class i implements LineHeightSpan {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final float f8401a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final int f8402b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final boolean f8403c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final boolean f8404d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final float f8405e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final int f8406f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f8407g = Integer.MIN_VALUE;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f8408h = Integer.MIN_VALUE;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f8409i = Integer.MIN_VALUE;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f8410j = Integer.MIN_VALUE;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f8411k;
    public int l;

    public i(float f6, int i6, boolean z6, boolean z7, float f7, int i7) {
        this.f8401a = f6;
        this.f8402b = i6;
        this.f8403c = z6;
        this.f8404d = z7;
        this.f8405e = f7;
        this.f8406f = i7;
        if ((0.0f > f7 || f7 > 1.0f) && f7 != -1.0f) {
            AbstractC0958a.b("topRatio should be in [0..1] range or -1");
        }
    }

    @Override // android.text.style.LineHeightSpan
    public final void chooseHeight(CharSequence charSequence, int i6, int i7, int i8, int i9, Paint.FontMetricsInt fontMetricsInt) {
        int i10 = fontMetricsInt.descent;
        int i11 = fontMetricsInt.ascent;
        if (i10 - i11 <= 0) {
            return;
        }
        boolean z6 = i6 == 0;
        boolean z7 = i7 == this.f8402b;
        int i12 = this.f8406f;
        boolean z8 = this.f8404d;
        boolean z9 = this.f8403c;
        if (z6 && z7 && z9 && z8 && i12 != 2) {
            return;
        }
        if (this.f8407g == Integer.MIN_VALUE) {
            int i13 = i10 - i11;
            int iCeil = (int) Math.ceil(this.f8401a);
            int i14 = iCeil - i13;
            if (i12 != 1 || i14 > 0) {
                float fAbs = this.f8405e;
                if (fAbs == -1.0f) {
                    fAbs = Math.abs(fontMetricsInt.ascent) / (fontMetricsInt.descent - fontMetricsInt.ascent);
                }
                int iCeil2 = (int) (i14 <= 0 ? Math.ceil(i14 * fAbs) : Math.ceil((1.0f - fAbs) * i14));
                int i15 = fontMetricsInt.descent;
                int i16 = iCeil2 + i15;
                this.f8409i = i16;
                int i17 = i16 - iCeil;
                this.f8408h = i17;
                if (i12 == 0 || i14 >= 0) {
                    if (z9) {
                        i17 = fontMetricsInt.ascent;
                    }
                    this.f8407g = i17;
                    if (z8) {
                        i16 = i15;
                    }
                    this.f8410j = i16;
                    this.f8411k = fontMetricsInt.ascent - i17;
                    this.l = i16 - i15;
                } else if (i12 == 2) {
                    this.f8407g = z9 ? Math.max(fontMetricsInt.ascent, i17) : Math.min(fontMetricsInt.ascent, i17);
                    this.f8410j = z8 ? Math.min(fontMetricsInt.descent, this.f8409i) : Math.max(fontMetricsInt.descent, this.f8409i);
                    this.f8411k = 0;
                    this.l = 0;
                }
            } else {
                int i18 = fontMetricsInt.ascent;
                this.f8408h = i18;
                int i19 = fontMetricsInt.descent;
                this.f8409i = i19;
                this.f8407g = i18;
                this.f8410j = i19;
                this.f8411k = 0;
                this.l = 0;
            }
        }
        fontMetricsInt.ascent = z6 ? this.f8407g : this.f8408h;
        fontMetricsInt.descent = z7 ? this.f8410j : this.f8409i;
    }
}
