package D1;

import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;

/* JADX INFO: loaded from: classes.dex */
public final class J {

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public int f1669A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public int f1670B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public int f1671C;
    public int D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public StaticLayout f1672E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public StaticLayout f1673F;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public int f1674G;
    public int H;

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    public int f1675I;

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public Rect f1676J;

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

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

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

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final Paint f1683g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final Paint f1684h;
    public CharSequence i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public Layout.Alignment f1685j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public Bitmap f1686k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public float f1687l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f1688m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public int f1689n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public float f1690o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f1691p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public float f1692q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public float f1693r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public int f1694s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f1695t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public int f1696u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public int f1697v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public int f1698w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public float f1699x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public float f1700y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public float f1701z;

    public J(Context context) {
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(null, new int[]{R.attr.lineSpacingExtra, R.attr.lineSpacingMultiplier}, 0, 0);
        this.f1681e = typedArrayObtainStyledAttributes.getDimensionPixelSize(0, 0);
        this.f1680d = typedArrayObtainStyledAttributes.getFloat(1, 1.0f);
        typedArrayObtainStyledAttributes.recycle();
        float fRound = Math.round((context.getResources().getDisplayMetrics().densityDpi * 2.0f) / 160.0f);
        this.f1677a = fRound;
        this.f1678b = fRound;
        this.f1679c = fRound;
        TextPaint textPaint = new TextPaint();
        this.f1682f = textPaint;
        textPaint.setAntiAlias(true);
        textPaint.setSubpixelText(true);
        Paint paint = new Paint();
        this.f1683g = paint;
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.FILL);
        Paint paint2 = new Paint();
        this.f1684h = paint2;
        paint2.setAntiAlias(true);
        paint2.setFilterBitmap(true);
    }

    public final void a(Canvas canvas, boolean z8) {
        Canvas canvas2;
        if (!z8) {
            this.f1676J.getClass();
            this.f1686k.getClass();
            canvas.drawBitmap(this.f1686k, (Rect) null, this.f1676J, this.f1684h);
            return;
        }
        StaticLayout staticLayout = this.f1672E;
        StaticLayout staticLayout2 = this.f1673F;
        if (staticLayout == null || staticLayout2 == null) {
            return;
        }
        int iSave = canvas.save();
        canvas.translate(this.f1674G, this.H);
        if (Color.alpha(this.f1696u) > 0) {
            Paint paint = this.f1683g;
            paint.setColor(this.f1696u);
            canvas2 = canvas;
            canvas2.drawRect(-this.f1675I, 0.0f, staticLayout.getWidth() + this.f1675I, staticLayout.getHeight(), paint);
        } else {
            canvas2 = canvas;
        }
        int i = this.f1698w;
        TextPaint textPaint = this.f1682f;
        if (i == 1) {
            textPaint.setStrokeJoin(Paint.Join.ROUND);
            textPaint.setStrokeWidth(this.f1677a);
            textPaint.setColor(this.f1697v);
            textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
            staticLayout2.draw(canvas2);
        } else {
            float f3 = this.f1678b;
            if (i == 2) {
                float f7 = this.f1679c;
                textPaint.setShadowLayer(f3, f7, f7, this.f1697v);
            } else if (i == 3 || i == 4) {
                boolean z9 = i == 3;
                int i5 = z9 ? -1 : this.f1697v;
                int i8 = z9 ? this.f1697v : -1;
                float f8 = f3 / 2.0f;
                textPaint.setColor(this.f1694s);
                textPaint.setStyle(Paint.Style.FILL);
                float f9 = -f8;
                textPaint.setShadowLayer(f3, f9, f9, i5);
                staticLayout2.draw(canvas2);
                textPaint.setShadowLayer(f3, f8, f8, i8);
            }
        }
        textPaint.setColor(this.f1694s);
        textPaint.setStyle(Paint.Style.FILL);
        staticLayout.draw(canvas2);
        textPaint.setShadowLayer(0.0f, 0.0f, 0.0f, 0);
        canvas2.restoreToCount(iSave);
    }
}
