package p073z;

import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Build;
import p020g0.C0736e;

/* renamed from: z.i */
/* loaded from: classes.dex */
public final class C1882i {

    /* renamed from: a */
    public static final ThreadLocal<C0736e<Rect, Rect>> f4684a = new ThreadLocal<>();

    /* renamed from: z.i$a */
    /* loaded from: classes.dex */
    public static class C1883a {
        /* renamed from: a */
        public static boolean m132a(Paint paint, String str) {
            boolean hasGlyph;
            hasGlyph = paint.hasGlyph(str);
            return hasGlyph;
        }
    }

    /* renamed from: a */
    public static boolean m134a(Paint paint, String str) {
        if (Build.VERSION.SDK_INT >= 23) {
            return C1883a.m132a(paint, str);
        }
        int length = str.length();
        if (length == 1 && Character.isWhitespace(str.charAt(0))) {
            return true;
        }
        float measureText = paint.measureText("\udfffd");
        float measureText2 = paint.measureText("m");
        float measureText3 = paint.measureText(str);
        float f = 0.0f;
        if (measureText3 == 0.0f) {
            return false;
        }
        if (str.codePointCount(0, str.length()) > 1) {
            if (measureText3 > measureText2 * 2.0f) {
                return false;
            }
            int i = 0;
            while (i < length) {
                int charCount = Character.charCount(str.codePointAt(i)) + i;
                f += paint.measureText(str, i, charCount);
                i = charCount;
            }
            if (measureText3 >= f) {
                return false;
            }
        }
        if (measureText3 != measureText) {
            return true;
        }
        C0736e<Rect, Rect> m133b = m133b();
        paint.getTextBounds("\udfffd", 0, 2, m133b.f2323a);
        paint.getTextBounds(str, 0, length, m133b.f2324b);
        return !m133b.f2323a.equals(m133b.f2324b);
    }

    /* renamed from: b */
    public static C0736e<Rect, Rect> m133b() {
        ThreadLocal<C0736e<Rect, Rect>> threadLocal = f4684a;
        C0736e<Rect, Rect> c0736e = threadLocal.get();
        if (c0736e == null) {
            C0736e<Rect, Rect> c0736e2 = new C0736e<>(new Rect(), new Rect());
            threadLocal.set(c0736e2);
            return c0736e2;
        }
        c0736e.f2323a.setEmpty();
        c0736e.f2324b.setEmpty();
        return c0736e;
    }
}