package androidx.emoji2.text;

import android.annotation.SuppressLint;
import android.graphics.Paint;
import android.text.style.ReplacementSpan;

/* JADX INFO: compiled from: EmojiSpan.java */
/* JADX INFO: loaded from: classes.dex */
public abstract class i extends ReplacementSpan {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private final g f2105f;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private final Paint.FontMetricsInt f2104e = new Paint.FontMetricsInt();

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private short f2106g = -1;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private float f2107h = 1.0f;

    i(g gVar) {
        androidx.core.util.h.g(gVar, "metadata cannot be null");
        this.f2105f = gVar;
    }

    public final g a() {
        return this.f2105f;
    }

    final int b() {
        return this.f2106g;
    }

    @Override // android.text.style.ReplacementSpan
    public int getSize(Paint paint, @SuppressLint({"UnknownNullness"}) CharSequence charSequence, int i3, int i4, Paint.FontMetricsInt fontMetricsInt) {
        paint.getFontMetricsInt(this.f2104e);
        Paint.FontMetricsInt fontMetricsInt2 = this.f2104e;
        this.f2107h = (Math.abs(fontMetricsInt2.descent - fontMetricsInt2.ascent) * 1.0f) / this.f2105f.e();
        this.f2105f.e();
        short sI = (short) (this.f2105f.i() * this.f2107h);
        this.f2106g = sI;
        if (fontMetricsInt != null) {
            Paint.FontMetricsInt fontMetricsInt3 = this.f2104e;
            fontMetricsInt.ascent = fontMetricsInt3.ascent;
            fontMetricsInt.descent = fontMetricsInt3.descent;
            fontMetricsInt.top = fontMetricsInt3.top;
            fontMetricsInt.bottom = fontMetricsInt3.bottom;
        }
        return sI;
    }
}
