package com.bef.effectsdk.text;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Build;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import com.bef.effectsdk.text.data.BitmapType;
import com.bef.effectsdk.text.data.CharLayout;
import com.bef.effectsdk.text.data.TextBitmapResult;
import com.bef.effectsdk.text.data.TextLayoutParam;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import java.util.ArrayList;

public class TextLayoutUtils {

    public enum COLOR_TYPE {
        COLOR_TYPE_RGBA,
        COLOR_TYPE_ALPHA
    }

    static {
        Covode.recordClassIndex(2843);
    }

    /* renamed from: com.bef.effectsdk.text.TextLayoutUtils$1  reason: invalid class name */
    public static /* synthetic */ class AnonymousClass1 {
        public static final /* synthetic */ int[] $SwitchMap$com$bef$effectsdk$text$TextLayoutUtils$COLOR_TYPE;
        public static final /* synthetic */ int[] $SwitchMap$com$bef$effectsdk$text$data$BitmapType;

        /* JADX WARNING: Can't wrap try/catch for region: R(11:0|1|2|3|(2:5|6)|7|9|10|11|12|14) */
        /* JADX WARNING: Code restructure failed: missing block: B:15:?, code lost:
            return;
         */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0033 */
        static {
            /*
                r0 = 2844(0xb1c, float:3.985E-42)
                com.bytedance.covode.number.Covode.recordClassIndex(r0)
                com.bef.effectsdk.text.TextLayoutUtils$COLOR_TYPE[] r0 = com.bef.effectsdk.text.TextLayoutUtils.COLOR_TYPE.values()
                int r0 = r0.length
                int[] r1 = new int[r0]
                $SwitchMap$com$bef$effectsdk$text$TextLayoutUtils$COLOR_TYPE = r1
                r3 = 1
                com.bef.effectsdk.text.TextLayoutUtils$COLOR_TYPE r0 = com.bef.effectsdk.text.TextLayoutUtils.COLOR_TYPE.COLOR_TYPE_ALPHA     // Catch:{ NoSuchFieldError -> 0x0017 }
                int r0 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0017 }
                r1[r0] = r3     // Catch:{ NoSuchFieldError -> 0x0017 }
            L_0x0017:
                r2 = 2
                int[] r1 = $SwitchMap$com$bef$effectsdk$text$TextLayoutUtils$COLOR_TYPE     // Catch:{ NoSuchFieldError -> 0x0022 }
                com.bef.effectsdk.text.TextLayoutUtils$COLOR_TYPE r0 = com.bef.effectsdk.text.TextLayoutUtils.COLOR_TYPE.COLOR_TYPE_RGBA     // Catch:{ NoSuchFieldError -> 0x0022 }
                int r0 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0022 }
                r1[r0] = r2     // Catch:{ NoSuchFieldError -> 0x0022 }
            L_0x0022:
                com.bef.effectsdk.text.data.BitmapType[] r0 = com.bef.effectsdk.text.data.BitmapType.values()
                int r0 = r0.length
                int[] r1 = new int[r0]
                $SwitchMap$com$bef$effectsdk$text$data$BitmapType = r1
                com.bef.effectsdk.text.data.BitmapType r0 = com.bef.effectsdk.text.data.BitmapType.TEXT_BITMAP_SHAKE_ALPHA     // Catch:{ NoSuchFieldError -> 0x0033 }
                int r0 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0033 }
                r1[r0] = r3     // Catch:{ NoSuchFieldError -> 0x0033 }
            L_0x0033:
                int[] r1 = $SwitchMap$com$bef$effectsdk$text$data$BitmapType     // Catch:{ NoSuchFieldError -> 0x003d }
                com.bef.effectsdk.text.data.BitmapType r0 = com.bef.effectsdk.text.data.BitmapType.TEXT_BITMAP_NEON_ALPHA     // Catch:{ NoSuchFieldError -> 0x003d }
                int r0 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x003d }
                r1[r0] = r2     // Catch:{ NoSuchFieldError -> 0x003d }
            L_0x003d:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.bef.effectsdk.text.TextLayoutUtils.AnonymousClass1.<clinit>():void");
        }
    }

    public static String[] splitLyric(String str) {
        int i;
        if (str == null || str.isEmpty()) {
            return null;
        }
        String[] split = str.replace("\n", " ").replace("\r", " ").split(" ");
        ArrayList arrayList = new ArrayList();
        int i2 = 0;
        int i3 = 0;
        while (i2 < split.length) {
            StringBuilder sb = new StringBuilder();
            if ((i3 % 5) % 3 == 0) {
                i = 6;
            } else {
                i = 10;
            }
            int i4 = 0;
            while (i2 < split.length && (split[i2].length() + i4 + 1 <= i || i4 <= 3)) {
                i4 += split[i2].length() + 1;
                int i5 = i2 + 1;
                sb.append(split[i2]);
                sb.append(" ");
                if (i5 == split.length - 1 && split[i5].length() < 3) {
                    sb.append(split[i5]);
                }
                i2 = i5;
            }
            i3++;
            arrayList.add(sb.substring(0, sb.length() - 1));
        }
        return (String[]) arrayList.toArray(new String[arrayList.size()]);
    }

    public static String[] lyricShakeSplit(String str) {
        boolean z;
        int length;
        if (str == null || str.isEmpty()) {
            return null;
        }
        String[] split = str.replace("\n", " ").replace(",", "").replace("\r", " ").split(" ");
        ArrayList arrayList = new ArrayList();
        StringBuilder sb = new StringBuilder();
        int i = 0;
        while (i < split.length) {
            if (!split[i].isEmpty()) {
                int length2 = sb.toString().length();
                if (length2 == 0) {
                    if (split[i].length() < 10) {
                        sb.append(split[i]);
                    } else if (split[i].length() == 10) {
                        arrayList.add(split[i]);
                    } else {
                        arrayList.add(split[i].substring(0, 10));
                        if ((split[i].length() - 10) % 9 == 0) {
                            z = true;
                            length = (split[i].length() - 10) / 9;
                        } else {
                            z = false;
                            length = ((split[i].length() - 10) / 9) + 1;
                        }
                        int i2 = 0;
                        while (true) {
                            if (i2 >= length) {
                                break;
                            }
                            if (i2 != 0) {
                                int i3 = ((i2 - 1) * 9) + 19;
                                if (i2 < length - 1) {
                                    sb.append("-");
                                    sb.append(split[i].substring(i3, (i2 * 9) + 19));
                                    String sb2 = sb.toString();
                                    arrayList.add(sb2);
                                    sb.delete(0, sb2.length());
                                } else if (z) {
                                    sb.append("-");
                                    sb.append(split[i].substring(i3, (i2 * 9) + 19));
                                    String sb3 = sb.toString();
                                    arrayList.add(sb3);
                                    sb.delete(0, sb3.length());
                                } else {
                                    int length3 = split[i].length();
                                    sb.append("-");
                                    sb.append(split[i].substring(i3, length3));
                                }
                            } else if (z) {
                                sb.append("-");
                                sb.append(split[i].substring(10, 19));
                                String sb4 = sb.toString();
                                arrayList.add(sb4);
                                sb.delete(0, sb4.length());
                            } else if (length == 1) {
                                int length4 = split[i].length();
                                sb.append("-");
                                sb.append(split[i].substring(10, length4));
                                break;
                            } else {
                                sb.append("-");
                                sb.append(split[i].substring(10, 19));
                                String sb5 = sb.toString();
                                arrayList.add(sb5);
                                sb.delete(0, sb5.length());
                            }
                            i2++;
                        }
                    }
                } else if (sb.toString().length() + split[i].length() + 1 <= 10) {
                    sb.append(" ");
                    sb.append(split[i]);
                } else {
                    arrayList.add(sb.toString());
                    sb.delete(0, length2);
                    i--;
                }
            }
            i++;
        }
        if (sb.toString().length() != 0) {
            arrayList.add(sb.toString());
        }
        return (String[]) arrayList.toArray(new String[arrayList.size()]);
    }

    public static TextBitmapResult generateBitmapAtlasAlphaUTF32(int[] iArr, TextLayoutParam textLayoutParam) {
        if (iArr == null || iArr.length <= 0) {
            return null;
        }
        return generateBitmapAtlasUTF8(new String(iArr, 0, iArr.length), textLayoutParam, COLOR_TYPE.COLOR_TYPE_ALPHA);
    }

    public static TextBitmapResult generateBitmapAtlasAlphaUTF8(String str, TextLayoutParam textLayoutParam) {
        if (str == null || str.isEmpty()) {
            return null;
        }
        return generateBitmapAtlasUTF8(str, textLayoutParam, COLOR_TYPE.COLOR_TYPE_ALPHA);
    }

    public static TextBitmapResult generateBitmapAtlasRGBAUTF32(int[] iArr, TextLayoutParam textLayoutParam) {
        if (iArr == null || iArr.length <= 0) {
            return null;
        }
        return generateBitmapAtlasUTF8(new String(iArr, 0, iArr.length), textLayoutParam, COLOR_TYPE.COLOR_TYPE_RGBA);
    }

    public static TextBitmapResult generateBitmapAtlasRGBAUTF8(String str, TextLayoutParam textLayoutParam) {
        if (str == null || str.isEmpty()) {
            return null;
        }
        return generateBitmapAtlasUTF8(str, textLayoutParam, COLOR_TYPE.COLOR_TYPE_RGBA);
    }

    public static TextBitmapResult generateBitmapNeonAlphaUTF32(int[] iArr, TextLayoutParam textLayoutParam) {
        if (iArr == null || iArr.length <= 0) {
            return null;
        }
        return generateBitmapNeonAlphaUTF8(new String(iArr, 0, iArr.length), textLayoutParam);
    }

    public static TextBitmapResult generateBitmapNeonAlphaUTF8(String str, TextLayoutParam textLayoutParam) {
        int i = AnonymousClass1.$SwitchMap$com$bef$effectsdk$text$data$BitmapType[BitmapType.valueOf(textLayoutParam.bitmapType).ordinal()];
        if (i == 1) {
            return generateTextAutoSizedShakeBitmap(str, textLayoutParam);
        }
        if (i != 2) {
            return null;
        }
        return generateTextAutoSizedNeonBitmap(str, textLayoutParam);
    }

    public static TextBitmapResult generateBitmapNormalAlphaUTF32(int[] iArr, TextLayoutParam textLayoutParam) {
        if (iArr == null || iArr.length <= 0) {
            return null;
        }
        return generateBitmapNormalUTF8(new String(iArr, 0, iArr.length), textLayoutParam, COLOR_TYPE.COLOR_TYPE_ALPHA);
    }

    public static TextBitmapResult generateBitmapNormalAlphaUTF8(String str, TextLayoutParam textLayoutParam) {
        if (str == null || str.isEmpty()) {
            return null;
        }
        return generateBitmapNormalUTF8(str, textLayoutParam, COLOR_TYPE.COLOR_TYPE_ALPHA);
    }

    public static TextBitmapResult generateBitmapNormalRGBAUTF32(int[] iArr, TextLayoutParam textLayoutParam) {
        if (iArr == null || iArr.length <= 0) {
            return null;
        }
        return generateBitmapNormalUTF8(new String(iArr, 0, iArr.length), textLayoutParam, COLOR_TYPE.COLOR_TYPE_RGBA);
    }

    public static TextBitmapResult generateBitmapNormalRGBAUTF8(String str, TextLayoutParam textLayoutParam) {
        if (str == null || str.isEmpty()) {
            return null;
        }
        return generateBitmapNormalUTF8(str, textLayoutParam, COLOR_TYPE.COLOR_TYPE_RGBA);
    }

    /*  JADX ERROR: JadxRuntimeException in pass: CodeShrinkVisitor
        jadx.core.utils.exceptions.JadxRuntimeException: Don't wrap MOVE or CONST insns: 0x000f: MOVE  (r3v0 com.bef.effectsdk.text.data.TextLayoutParam) = (r25v0 com.bef.effectsdk.text.data.TextLayoutParam)
        	at jadx.core.dex.instructions.args.InsnArg.wrapArg(InsnArg.java:164)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.assignInline(CodeShrinkVisitor.java:133)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.checkInline(CodeShrinkVisitor.java:118)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkBlock(CodeShrinkVisitor.java:65)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkMethod(CodeShrinkVisitor.java:43)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.visit(CodeShrinkVisitor.java:35)
        */
    public static com.bef.effectsdk.text.data.TextBitmapResult generateTextAutoSizedNeonBitmap(java.lang.String r24, com.bef.effectsdk.text.data.TextLayoutParam r25) {
        /*
            r0 = 16716(0x414c, float:2.3424E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r0)
            java.lang.String[] r8 = splitLyric(r24)
            boolean r0 = android.text.TextUtils.isEmpty(r24)
            if (r0 != 0) goto L_0x0013
            r3 = r25
            if (r3 != 0) goto L_0x001a
        L_0x0013:
            r1 = 16716(0x414c, float:2.3424E-41)
            r0 = 0
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r1)
            return r0
        L_0x001a:
            android.text.TextPaint r7 = new android.text.TextPaint
            r7.<init>()
            android.graphics.Paint$Align r0 = android.graphics.Paint.Align.LEFT
            r7.setTextAlign(r0)
            r2 = 1
            r7.setAntiAlias(r2)
            java.lang.String r0 = r3.familyName
            boolean r0 = android.text.TextUtils.isEmpty(r0)
            if (r0 != 0) goto L_0x0043
            java.lang.String r0 = r3.fontPath
            boolean r0 = android.text.TextUtils.isEmpty(r0)
            if (r0 != 0) goto L_0x0043
            java.lang.String r1 = r3.fontPath
            java.lang.String r0 = r3.familyName
            android.graphics.Typeface r0 = com.bef.effectsdk.text.FontCache.getFromFile(r1, r0)
            r7.setTypeface(r0)
        L_0x0043:
            android.graphics.Paint$FontMetrics r0 = r7.getFontMetrics()
            float r1 = r0.top
            android.graphics.Paint$FontMetrics r0 = r7.getFontMetrics()
            float r0 = r0.ascent
            r11 = 0
            int r0 = (r1 > r0 ? 1 : (r1 == r0 ? 0 : -1))
            if (r0 >= 0) goto L_0x00b4
            r15 = 1
        L_0x0055:
            com.bef.effectsdk.text.data.TextBitmapResult r6 = new com.bef.effectsdk.text.data.TextBitmapResult
            r6.<init>()
            r6.channel = r2
            int r0 = r8.length
            r6.lineCount = r0
            r6.type = r11
            int r0 = r8.length
            com.bef.effectsdk.text.data.CharLayout[] r0 = new com.bef.effectsdk.text.data.CharLayout[r0]
            r6.charLayouts = r0
            int r0 = r8.length
            int[] r5 = new int[r0]
            r12 = 0
            r2 = 0
            r4 = 0
        L_0x006c:
            int r0 = r8.length
            if (r2 >= r0) goto L_0x00b6
            r9 = 10
            r1 = r8[r2]
            r0 = 1092616192(0x41200000, float:10.0)
            r7.setTextSize(r0)
            int r0 = r1.length()
            float r10 = r7.measureText(r1, r11, r0)
        L_0x0080:
            int r0 = r3.lineWidth
            float r0 = (float) r0
            int r0 = (r10 > r0 ? 1 : (r10 == r0 ? 0 : -1))
            if (r0 > 0) goto L_0x0096
            int r9 = r9 + 2
            float r0 = (float) r9
            r7.setTextSize(r0)
            int r0 = r1.length()
            float r10 = r7.measureText(r1, r11, r0)
            goto L_0x0080
        L_0x0096:
            int r0 = r9 + -2
            r5[r2] = r0
            r0 = r5[r2]
            float r0 = (float) r0
            r7.setTextSize(r0)
            android.graphics.Paint$FontMetrics r0 = r7.getFontMetrics()
            if (r15 == 0) goto L_0x00af
            float r1 = r0.bottom
            float r0 = r0.top
        L_0x00aa:
            float r1 = r1 - r0
            float r4 = r4 + r1
            int r2 = r2 + 1
            goto L_0x006c
        L_0x00af:
            float r1 = r0.descent
            float r0 = r0.ascent
            goto L_0x00aa
        L_0x00b4:
            r15 = 0
            goto L_0x0055
        L_0x00b6:
            int r2 = r3.lineWidth
            int r1 = (int) r4
            android.graphics.Bitmap$Config r0 = android.graphics.Bitmap.Config.ALPHA_8
            android.graphics.Bitmap r0 = android.graphics.Bitmap.createBitmap(r2, r1, r0)
            android.graphics.Canvas r3 = new android.graphics.Canvas
            r3.<init>(r0)
            r6.bitmap = r0
            r2 = 0
            r14 = 0
        L_0x00c8:
            int r0 = r8.length
            if (r2 >= r0) goto L_0x0162
            r9 = r8[r2]
            r0 = r5[r2]
            float r0 = (float) r0
            r7.setTextSize(r0)
            android.graphics.Paint$FontMetrics r1 = r7.getFontMetrics()
            int r13 = android.os.Build.VERSION.SDK_INT
            r0 = 23
            r10 = 1065353216(0x3f800000, float:1.0)
            if (r13 < r0) goto L_0x013e
            int r13 = r9.length()
            int r0 = r3.getWidth()
            android.text.StaticLayout$Builder r9 = android.text.StaticLayout.Builder.obtain(r9, r11, r13, r7, r0)
            android.text.Layout$Alignment r0 = android.text.Layout.Alignment.ALIGN_NORMAL
            android.text.StaticLayout$Builder r0 = r9.setAlignment(r0)
            android.text.StaticLayout$Builder r0 = r0.setLineSpacing(r12, r10)
            android.text.StaticLayout$Builder r0 = r0.setIncludePad(r11)
            android.text.StaticLayout r0 = r0.build()
        L_0x00fd:
            r0.draw(r3)
            com.bef.effectsdk.text.data.CharLayout r10 = new com.bef.effectsdk.text.data.CharLayout
            r10.<init>()
            if (r15 == 0) goto L_0x0131
            float r9 = r1.bottom
            float r0 = r1.top
            float r9 = r9 - r0
            float r0 = r1.top
            float r0 = r14 - r0
            float r0 = r0 / r4
            r10.baseline = r0
        L_0x0113:
            float r0 = r14 / r4
            r10.top = r0
            float r14 = r14 + r9
            float r0 = r14 / r4
            r10.bottom = r0
            r1 = 0
            r10.left = r1
            r0 = 1065353216(0x3f800000, float:1.0)
            r10.right = r0
            com.bef.effectsdk.text.data.CharLayout[] r0 = r6.charLayouts
            r0[r2] = r10
            r3.translate(r1, r9)
            int r2 = r2 + 1
            r0 = 16716(0x414c, float:2.3424E-41)
            r12 = 0
            r11 = 0
            goto L_0x00c8
        L_0x0131:
            float r9 = r1.descent
            float r0 = r1.ascent
            float r9 = r9 - r0
            float r0 = r1.ascent
            float r0 = r14 - r0
            float r0 = r0 / r4
            r10.baseline = r0
            goto L_0x0113
        L_0x013e:
            android.text.StaticLayout r0 = new android.text.StaticLayout
            r18 = 0
            int r19 = r9.length()
            int r21 = r3.getWidth()
            android.text.Layout$Alignment r22 = android.text.Layout.Alignment.ALIGN_NORMAL
            r10 = 1065353216(0x3f800000, float:1.0)
            r10 = 0
            r10 = 0
            r10 = 1065353216(0x3f800000, float:1.0)
            r23 = 1065353216(0x3f800000, float:1.0)
            r24 = 0
            r25 = 0
            r20 = r7
            r17 = r9
            r16 = r0
            r16.<init>(r17, r18, r19, r20, r21, r22, r23, r24, r25)
            goto L_0x00fd
        L_0x0162:
            r0 = 16716(0x414c, float:2.3424E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)
            return r6
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bef.effectsdk.text.TextLayoutUtils.generateTextAutoSizedNeonBitmap(java.lang.String, com.bef.effectsdk.text.data.TextLayoutParam):com.bef.effectsdk.text.data.TextBitmapResult");
    }

    public static TextBitmapResult generateTextAutoSizedShakeBitmap(String str, TextLayoutParam textLayoutParam) {
        boolean z;
        StaticLayout staticLayout;
        MethodCollector.i(16582);
        String[] lyricShakeSplit = lyricShakeSplit(str);
        if (TextUtils.isEmpty(str)) {
            MethodCollector.o(16582);
            return null;
        }
        TextPaint textPaint = new TextPaint();
        textPaint.setAntiAlias(true);
        TextLayoutParam textLayoutParam2 = textLayoutParam;
        if (!TextUtils.isEmpty(textLayoutParam2.familyName) && !TextUtils.isEmpty(textLayoutParam2.fontPath)) {
            textPaint.setTypeface(FontCache.getFromFile(textLayoutParam2.fontPath, textLayoutParam2.familyName));
        }
        textPaint.setTextSize(textLayoutParam2.fontSize);
        boolean z2 = false;
        if (textPaint.getFontMetrics().top < textPaint.getFontMetrics().ascent) {
            z = true;
        } else {
            z = false;
        }
        Paint.FontMetrics fontMetrics = textPaint.getFontMetrics();
        ArrayList arrayList = new ArrayList();
        float f = (float) textLayoutParam2.lineWidth;
        float f2 = 0.0f;
        float f3 = 0.0f;
        int i = 0;
        int i2 = 0;
        while (i2 < lyricShakeSplit.length) {
            String str2 = lyricShakeSplit[i2];
            if (Build.VERSION.SDK_INT >= 23) {
                staticLayout = StaticLayout.Builder.obtain(str2, z2 ? 1 : 0, str2.length(), textPaint, (int) f).setAlignment(Layout.Alignment.ALIGN_OPPOSITE).setLineSpacing(f2, 1.0f).setIncludePad(z2).build();
            } else {
                staticLayout = r19;
                StaticLayout staticLayout2 = new StaticLayout(str2, 0, str2.length(), textPaint, (int) f, Layout.Alignment.ALIGN_OPPOSITE, 1.0f, 0.0f, false);
            }
            i += staticLayout.getLineCount();
            arrayList.add(staticLayout);
            f3 += (float) staticLayout.getHeight();
            i2++;
            f2 = 0.0f;
            z2 = false;
        }
        TextBitmapResult textBitmapResult = new TextBitmapResult();
        textBitmapResult.channel = 1;
        textBitmapResult.lineCount = i;
        textBitmapResult.type = 0;
        textBitmapResult.charLayouts = new CharLayout[i];
        Bitmap createBitmap = Bitmap.createBitmap(textLayoutParam2.lineWidth, (int) f3, Bitmap.Config.ALPHA_8);
        Canvas canvas = new Canvas(createBitmap);
        textBitmapResult.bitmap = createBitmap;
        float f4 = 0.0f;
        int i3 = 0;
        for (int i4 = 0; i4 < lyricShakeSplit.length; i4++) {
            float height = (float) ((StaticLayout) arrayList.get(i4)).getHeight();
            float lineCount = height / ((float) ((StaticLayout) arrayList.get(i4)).getLineCount());
            for (int i5 = 0; i5 < ((StaticLayout) arrayList.get(i4)).getLineCount(); i5++) {
                CharLayout charLayout = new CharLayout();
                float lineWidth = ((StaticLayout) arrayList.get(i4)).getLineWidth(i5);
                if (z) {
                    charLayout.baseline = (f4 - fontMetrics.top) / f3;
                } else {
                    charLayout.baseline = (f4 - fontMetrics.ascent) / f3;
                }
                charLayout.top = f4 / f3;
                f4 += lineCount;
                charLayout.bottom = (f4 - (Math.abs(fontMetrics.bottom - fontMetrics.descent) / 2.0f)) / f3;
                if (textLayoutParam2.textAlign == 0) {
                    charLayout.left = 0.0f;
                    charLayout.right = (f - lineWidth) / f;
                } else {
                    charLayout.left = (f - lineWidth) / f;
                    charLayout.right = 1.0f;
                }
                textBitmapResult.charLayouts[i3] = charLayout;
                i3++;
            }
            ((StaticLayout) arrayList.get(i4)).draw(canvas);
            canvas.translate(0.0f, height * ((float) ((StaticLayout) arrayList.get(i4)).getLineCount()));
        }
        MethodCollector.o(16582);
        return textBitmapResult;
    }

    /* JADX WARNING: Removed duplicated region for block: B:23:0x0077  */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x00d7  */
    /* JADX WARNING: Removed duplicated region for block: B:33:0x00e0  */
    /* JADX WARNING: Removed duplicated region for block: B:37:0x0112  */
    /* JADX WARNING: Removed duplicated region for block: B:75:0x02e4  */
    /* JADX WARNING: Removed duplicated region for block: B:76:0x02e7  */
    /* JADX WARNING: Removed duplicated region for block: B:84:0x032e  */
    /* JADX WARNING: Removed duplicated region for block: B:86:0x0339  */
    /* JADX WARNING: Removed duplicated region for block: B:88:0x0340  */
    /* JADX WARNING: Removed duplicated region for block: B:89:0x0349  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static com.bef.effectsdk.text.data.TextBitmapResult generateBitmapAtlasUTF8(java.lang.String r27, com.bef.effectsdk.text.data.TextLayoutParam r28, com.bef.effectsdk.text.TextLayoutUtils.COLOR_TYPE r29) {
        /*
            r3 = 7132(0x1bdc, float:9.994E-42)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r3)
            r2 = r27
            boolean r1 = r2.isEmpty()
            r0 = 0
            if (r1 == 0) goto L_0x0012
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r3)
            return r0
        L_0x0012:
            android.graphics.Typeface r4 = android.graphics.Typeface.DEFAULT
            r7 = r28
            java.lang.String r0 = r7.familyName
            if (r0 == 0) goto L_0x0036
            java.lang.String r0 = r7.familyName
            boolean r0 = r0.isEmpty()
            if (r0 != 0) goto L_0x0036
            java.lang.String r0 = r7.fontPath
            if (r0 == 0) goto L_0x0308
            java.lang.String r0 = r7.fontPath
            boolean r0 = r0.isEmpty()
            if (r0 != 0) goto L_0x0308
            java.lang.String r1 = r7.fontPath
            java.lang.String r0 = r7.familyName
            android.graphics.Typeface r4 = com.bef.effectsdk.text.FontCache.getFromFile(r1, r0)
        L_0x0036:
            int r8 = r7.textColor
            int r6 = r7.backColor
            int r3 = r7.shadowColor
            int[] r1 = com.bef.effectsdk.text.TextLayoutUtils.AnonymousClass1.$SwitchMap$com$bef$effectsdk$text$TextLayoutUtils$COLOR_TYPE
            int r0 = r29.ordinal()
            r0 = r1[r0]
            r5 = 1
            if (r0 == r5) goto L_0x02fa
            r0 = r8 & 255(0xff, float:3.57E-43)
            int r9 = r0 << 24
            int r0 = r8 >> 8
            r1 = 16777215(0xffffff, float:2.3509886E-38)
            r0 = r0 & r1
            int r9 = r9 + r0
            r0 = r6 & 255(0xff, float:3.57E-43)
            int r26 = r0 << 24
            int r0 = r6 >> 8
            r0 = r0 & r1
            int r26 = r26 + r0
            r0 = r3 & 255(0xff, float:3.57E-43)
            int r8 = r0 << 24
            int r0 = r3 >> 8
            r0 = r0 & r1
            int r8 = r8 + r0
        L_0x0063:
            android.graphics.Paint$Style r3 = android.graphics.Paint.Style.FILL
            int r1 = r7.paintStyle
            r0 = 2
            r6 = 0
            if (r1 == 0) goto L_0x02f6
            if (r1 == r5) goto L_0x02f0
            if (r1 == r0) goto L_0x02ea
        L_0x006f:
            r0 = 0
        L_0x0070:
            android.text.TextPaint r1 = new android.text.TextPaint
            r1.<init>(r5)
            if (r4 == 0) goto L_0x007a
            r1.setTypeface(r4)
        L_0x007a:
            r1.setColor(r9)
            r1.setStyle(r3)
            r1.setStrokeWidth(r0)
            float r0 = r7.fontSize
            r1.setTextSize(r0)
            float r4 = r7.shadowRadius
            float r3 = r7.shadowDx
            float r0 = r7.shadowDy
            r1.setShadowLayer(r4, r3, r0, r8)
            int r4 = r7.lineWidth
            r0 = 2048(0x800, float:2.87E-42)
            if (r4 > r0) goto L_0x0099
            if (r4 != 0) goto L_0x009b
        L_0x0099:
            r4 = 2048(0x800, float:2.87E-42)
        L_0x009b:
            com.bef.effectsdk.text.data.TextBitmapResult r3 = new com.bef.effectsdk.text.data.TextBitmapResult
            r3.<init>()
            r0 = 4
            r3.channel = r0
            r0 = 0
            r3.lineCount = r0
            r3.type = r5
            java.util.ArrayList r25 = new java.util.ArrayList
            r25.<init>()
            java.util.HashMap r24 = new java.util.HashMap
            r24.<init>()
            java.util.ArrayList r23 = new java.util.ArrayList
            r23.<init>()
            float r0 = r7.shadowDx
            float r22 = java.lang.Math.abs(r0)
            float r0 = r7.shadowRadius
            r21 = 1073741824(0x40000000, float:2.0)
            float r0 = r0 / r21
            float r22 = r22 + r0
            float r0 = r7.shadowDy
            float r20 = java.lang.Math.abs(r0)
            float r0 = r7.shadowRadius
            float r0 = r0 / r21
            float r20 = r20 + r0
            float r0 = r7.letterSpacing
            int r0 = (r0 > r6 ? 1 : (r0 == r6 ? 0 : -1))
            if (r0 <= 0) goto L_0x02e7
            float r0 = r7.letterSpacing
        L_0x00d9:
            int r9 = (int) r0
            float r0 = r7.lineSpacingAdd
            int r0 = (r0 > r6 ? 1 : (r0 == r6 ? 0 : -1))
            if (r0 <= 0) goto L_0x02e4
            float r0 = r7.lineSpacingAdd
        L_0x00e2:
            int r0 = (int) r0
            r19 = r0
            float r0 = r7.shadowDx
            float r5 = -r0
            float r0 = r7.shadowRadius
            float r0 = r0 / r21
            float r5 = r5 + r0
            float r0 = java.lang.Math.max(r5, r6)
            int r11 = (int) r0
            int r11 = r11 + r9
            r0 = 1
            int r11 = r11 + r0
            float r0 = r7.shadowDy
            float r5 = -r0
            float r0 = r7.shadowRadius
            float r0 = r0 / r21
            float r5 = r5 + r0
            r0 = 0
            float r5 = java.lang.Math.max(r5, r0)
            float r0 = r7.fontSize
            float r5 = r5 + r0
            int r5 = (int) r5
            int r5 = r5 + r19
            r0 = 1
            int r5 = r5 + r0
            r6 = 0
            r10 = 0
        L_0x010c:
            int r0 = r2.length()
            if (r10 >= r0) goto L_0x0312
            com.bef.effectsdk.text.data.CharLayout r8 = new com.bef.effectsdk.text.data.CharLayout
            r8.<init>()
            r0 = 0
            r8.charCode = r0
            r8.isEmoji = r0
            int r18 = r6 + 1
            r8.charId = r6
            r6 = 1
        L_0x0121:
            int r0 = r2.length()
            int r13 = r6 + r10
            int r12 = r13 + 1
            if (r0 <= r12) goto L_0x018b
            int r0 = r13 + -1
            java.lang.String r15 = r2.substring(r0, r13)
            java.lang.String r12 = r2.substring(r13, r12)
            java.lang.String r14 = "?"
            int r0 = r15.compareTo(r14)
            java.lang.String r13 = "?"
            if (r0 < 0) goto L_0x0163
            int r0 = r15.compareTo(r13)
            if (r0 > 0) goto L_0x0163
            java.lang.String r0 = "?"
            int r0 = r12.compareTo(r0)
            if (r0 < 0) goto L_0x0163
            java.lang.String r0 = "?"
            int r0 = r12.compareTo(r0)
            if (r0 > 0) goto L_0x0163
            r0 = 1
            r8.isEmoji = r0
            int r0 = r6 + 1
            short r6 = (short) r0
            int r12 = r2.length()
            int r0 = r10 + 3
            if (r12 < r0) goto L_0x018b
        L_0x0163:
            int r0 = r10 + r6
            int r12 = r0 + 1
            java.lang.String r15 = r2.substring(r0, r12)
            r16 = 2
            int r0 = r0 + 2
            java.lang.String r12 = r2.substring(r12, r0)
            java.lang.String r0 = "‍"
            int r0 = r15.compareTo(r0)
            if (r0 != 0) goto L_0x018c
            int r0 = r12.compareTo(r14)
            if (r0 < 0) goto L_0x018c
            int r0 = r12.compareTo(r13)
            if (r0 > 0) goto L_0x018c
            int r0 = r6 + 2
            short r6 = (short) r0
            goto L_0x0121
        L_0x018b:
            r0 = 2
        L_0x018c:
            boolean r0 = r8.isEmoji
            if (r0 != 0) goto L_0x01b6
            int r0 = r10 + r6
            java.lang.String r0 = r2.substring(r10, r0)
            byte[] r15 = r0.getBytes()
            r0 = 0
            r8.charCode = r0
            r14 = 0
        L_0x019e:
            int r0 = r15.length
            if (r14 >= r0) goto L_0x01b6
            int r13 = r8.charCode
            byte r0 = r15[r14]
            r12 = r0 & 255(0xff, float:3.57E-43)
            int r0 = r15.length
            int r0 = r0 - r14
            r16 = 1
            int r0 = r0 + -1
            int r0 = r0 * 8
            int r12 = r12 << r0
            int r13 = r13 + r12
            r8.charCode = r13
            int r14 = r14 + 1
            goto L_0x019e
        L_0x01b6:
            int r0 = r8.charCode
            java.lang.Integer r12 = java.lang.Integer.valueOf(r0)
            r0 = r24
            java.lang.Object r12 = r0.get(r12)
            com.bef.effectsdk.text.data.CharLayout r12 = (com.bef.effectsdk.text.data.CharLayout) r12
            if (r12 == 0) goto L_0x01ca
            boolean r0 = r8.isEmoji
            if (r0 == 0) goto L_0x02b7
        L_0x01ca:
            android.graphics.Rect r14 = new android.graphics.Rect
            r14.<init>()
            int r13 = r10 + r6
            r1.getTextBounds(r2, r10, r13, r14)
            int r0 = r14.left
            float r12 = (float) r0
            float r15 = r7.shadowDx
            float r0 = r7.shadowRadius
            float r0 = r0 / r21
            float r15 = r15 - r0
            r0 = 0
            float r0 = java.lang.Math.min(r15, r0)
            float r12 = r12 + r0
            int r0 = (int) r12
            r14.left = r0
            int r0 = r14.right
            float r12 = (float) r0
            float r15 = r7.shadowDx
            float r0 = r7.shadowRadius
            float r0 = r0 / r21
            float r15 = r15 + r0
            r0 = 0
            float r0 = java.lang.Math.max(r15, r0)
            float r12 = r12 + r0
            int r0 = (int) r12
            r14.right = r0
            int r0 = r14.bottom
            float r12 = (float) r0
            float r15 = r7.shadowDy
            float r0 = r7.shadowRadius
            float r0 = r0 / r21
            float r15 = r15 + r0
            r0 = 0
            float r0 = java.lang.Math.max(r15, r0)
            float r12 = r12 + r0
            int r0 = (int) r12
            r14.bottom = r0
            int r0 = r14.top
            float r12 = (float) r0
            float r15 = r7.shadowDy
            float r0 = r7.shadowRadius
            float r0 = r0 / r21
            float r15 = r15 - r0
            r0 = 0
            float r0 = java.lang.Math.min(r15, r0)
            float r12 = r12 + r0
            int r0 = (int) r12
            r14.top = r0
            float r12 = r1.measureText(r2, r10, r13)
            r8.advance = r12
            float r15 = (float) r11
            float r15 = r15 + r12
            float r15 = r15 + r22
            float r0 = (float) r9
            r17 = r0
            float r15 = r15 + r17
            r16 = 1065353216(0x3f800000, float:1.0)
            float r15 = r15 + r16
            float r0 = (float) r4
            int r0 = (r15 > r0 ? 1 : (r15 == r0 ? 0 : -1))
            if (r0 < 0) goto L_0x025c
            float r0 = r7.shadowDx
            float r11 = -r0
            float r0 = r7.shadowRadius
            float r0 = r0 / r21
            float r11 = r11 + r0
            r0 = 0
            float r0 = java.lang.Math.max(r11, r0)
            int r11 = (int) r0
            int r11 = r11 + r9
            r0 = 1
            int r11 = r11 + 1
            float r15 = (float) r5
            float r5 = r7.fontSize
            float r5 = r5 + r20
            r0 = r19
            float r0 = (float) r0
            float r5 = r5 + r0
            float r5 = r5 + r16
            float r15 = r15 + r5
            int r5 = (int) r15
            r0 = 4194304(0x400000, float:5.877472E-39)
            int r0 = r0 / r4
            if (r5 >= r0) goto L_0x0312
        L_0x025c:
            android.graphics.Rect r0 = new android.graphics.Rect
            r0.<init>(r10, r13, r11, r5)
            r27 = r23
            r28 = r0
            r27.add(r28)
            float r0 = (float) r5
            r8.baseline = r0
            float r13 = (float) r11
            r8.origin = r13
            int r0 = r14.left
            float r0 = (float) r0
            r8.pos_left = r0
            int r0 = r14.top
            float r0 = (float) r0
            r8.pos_top = r0
            int r0 = r14.right
            float r0 = (float) r0
            r8.pos_right = r0
            int r0 = r14.bottom
            float r0 = (float) r0
            r8.pos_bottom = r0
            int r0 = r14.left
            int r0 = r0 + r11
            float r0 = (float) r0
            r8.left = r0
            int r0 = r14.top
            int r0 = r0 + r5
            float r0 = (float) r0
            r8.top = r0
            int r0 = r14.right
            int r0 = r0 + r11
            float r0 = (float) r0
            r8.right = r0
            int r0 = r14.bottom
            int r0 = r0 + r5
            float r0 = (float) r0
            r8.bottom = r0
            int r0 = r8.charCode
            java.lang.Integer r11 = java.lang.Integer.valueOf(r0)
            r0 = r24
            r0.put(r11, r8)
            float r12 = r12 + r22
            float r12 = r12 + r17
            float r12 = r12 + r16
            float r13 = r13 + r12
            int r11 = (int) r13
        L_0x02ad:
            r0 = r25
            r0.add(r8)
            int r10 = r10 + r6
            r6 = r18
            goto L_0x010c
        L_0x02b7:
            float r0 = r12.pos_left
            r8.pos_left = r0
            float r0 = r12.pos_top
            r8.pos_top = r0
            float r0 = r12.pos_right
            r8.pos_right = r0
            float r0 = r12.pos_bottom
            r8.pos_bottom = r0
            float r0 = r12.left
            r8.left = r0
            float r0 = r12.top
            r8.top = r0
            float r0 = r12.right
            r8.right = r0
            float r0 = r12.bottom
            r8.bottom = r0
            float r0 = r12.baseline
            r8.baseline = r0
            float r0 = r12.origin
            r8.origin = r0
            float r0 = r12.advance
            r8.advance = r0
            goto L_0x02ad
        L_0x02e4:
            r0 = 0
            goto L_0x00e2
        L_0x02e7:
            r0 = 0
            goto L_0x00d9
        L_0x02ea:
            android.graphics.Paint$Style r3 = android.graphics.Paint.Style.FILL_AND_STROKE
            float r0 = r7.strokeWidth
            goto L_0x0070
        L_0x02f0:
            android.graphics.Paint$Style r3 = android.graphics.Paint.Style.STROKE
            float r0 = r7.strokeWidth
            goto L_0x0070
        L_0x02f6:
            android.graphics.Paint$Style r3 = android.graphics.Paint.Style.FILL
            goto L_0x006f
        L_0x02fa:
            r0 = r8 & 255(0xff, float:3.57E-43)
            int r9 = r0 << 24
            r0 = r6 & 255(0xff, float:3.57E-43)
            int r26 = r0 << 24
            r0 = r3 & 255(0xff, float:3.57E-43)
            int r8 = r0 << 24
            goto L_0x0063
        L_0x0308:
            java.lang.String r1 = r7.familyName
            int r0 = r7.fontStyle
            android.graphics.Typeface r4 = com.bef.effectsdk.text.FontCache.getFromSystem(r1, r0)
            goto L_0x0036
        L_0x0312:
            r0 = 0
            com.bef.effectsdk.text.data.CharLayout[] r6 = new com.bef.effectsdk.text.data.CharLayout[r0]
            r0 = r25
            java.lang.Object[] r0 = r0.toArray(r6)
            com.bef.effectsdk.text.data.CharLayout[] r0 = (com.bef.effectsdk.text.data.CharLayout[]) r0
            r3.charLayouts = r0
            float r0 = r7.fontSize
            int r0 = (int) r0
            int r5 = r5 + r0
            int[] r6 = com.bef.effectsdk.text.TextLayoutUtils.AnonymousClass1.$SwitchMap$com$bef$effectsdk$text$TextLayoutUtils$COLOR_TYPE
            int r0 = r29.ordinal()
            r0 = r6[r0]
            r6 = 1
            if (r0 == r6) goto L_0x0340
            android.graphics.Bitmap$Config r0 = android.graphics.Bitmap.Config.ARGB_8888
            android.graphics.Bitmap r10 = android.graphics.Bitmap.createBitmap(r4, r5, r0)
            r0 = 4
            r3.channel = r0
        L_0x0337:
            if (r10 != 0) goto L_0x0349
            r0 = 7132(0x1bdc, float:9.994E-42)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)
            r0 = 0
            return r0
        L_0x0340:
            android.graphics.Bitmap$Config r0 = android.graphics.Bitmap.Config.ALPHA_8
            android.graphics.Bitmap r10 = android.graphics.Bitmap.createBitmap(r4, r5, r0)
            r3.channel = r6
            goto L_0x0337
        L_0x0349:
            android.graphics.Paint r8 = new android.graphics.Paint
            r8.<init>()
            r0 = r26
            r8.setColor(r0)
            android.graphics.Canvas r6 = new android.graphics.Canvas
            r6.<init>(r10)
            android.graphics.Rect r0 = new android.graphics.Rect
            r7 = 0
            r0.<init>(r7, r7, r4, r5)
            r6.drawRect(r0, r8)
            java.util.Iterator r12 = r23.iterator()
        L_0x0365:
            boolean r0 = r12.hasNext()
            if (r0 == 0) goto L_0x0383
            java.lang.Object r11 = r12.next()
            android.graphics.Rect r11 = (android.graphics.Rect) r11
            int r8 = r11.left
            int r0 = r11.top
            java.lang.String r9 = r2.substring(r8, r0)
            int r0 = r11.right
            float r8 = (float) r0
            int r0 = r11.bottom
            float r0 = (float) r0
            r6.drawText(r9, r8, r0, r1)
            goto L_0x0365
        L_0x0383:
            r3.bitmap = r10
        L_0x0385:
            com.bef.effectsdk.text.data.CharLayout[] r0 = r3.charLayouts
            int r0 = r0.length
            if (r7 >= r0) goto L_0x03b3
            com.bef.effectsdk.text.data.CharLayout[] r0 = r3.charLayouts
            r1 = r0[r7]
            float r0 = r1.bottom
            float r2 = (float) r5
            float r0 = r0 / r2
            r1.bottom = r0
            com.bef.effectsdk.text.data.CharLayout[] r0 = r3.charLayouts
            r1 = r0[r7]
            float r0 = r1.top
            float r0 = r0 / r2
            r1.top = r0
            com.bef.effectsdk.text.data.CharLayout[] r0 = r3.charLayouts
            r1 = r0[r7]
            float r0 = r1.left
            float r2 = (float) r4
            float r0 = r0 / r2
            r1.left = r0
            com.bef.effectsdk.text.data.CharLayout[] r0 = r3.charLayouts
            r1 = r0[r7]
            float r0 = r1.right
            float r0 = r0 / r2
            r1.right = r0
            int r7 = r7 + 1
            goto L_0x0385
        L_0x03b3:
            r0 = 0
            r6.setBitmap(r0)
            r0 = 7132(0x1bdc, float:9.994E-42)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)
            return r3
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bef.effectsdk.text.TextLayoutUtils.generateBitmapAtlasUTF8(java.lang.String, com.bef.effectsdk.text.data.TextLayoutParam, com.bef.effectsdk.text.TextLayoutUtils$COLOR_TYPE):com.bef.effectsdk.text.data.TextBitmapResult");
    }

    /* JADX WARNING: type inference failed for: r6v6, types: [android.text.Layout] */
    /* JADX WARNING: type inference failed for: r18v2, types: [android.text.StaticLayout] */
    /* JADX WARNING: type inference failed for: r6v7 */
    /* JADX WARNING: type inference failed for: r18v3, types: [android.text.BoringLayout] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x0076  */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x0082  */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x008c  */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x00a0  */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x00a4  */
    /* JADX WARNING: Removed duplicated region for block: B:44:0x00a8  */
    /* JADX WARNING: Removed duplicated region for block: B:47:0x00b2  */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x0108  */
    /* JADX WARNING: Removed duplicated region for block: B:57:0x010f  */
    /* JADX WARNING: Removed duplicated region for block: B:72:0x015a  */
    /* JADX WARNING: Removed duplicated region for block: B:73:0x0182  */
    /* JADX WARNING: Removed duplicated region for block: B:79:0x01b7  */
    /* JADX WARNING: Removed duplicated region for block: B:80:0x01bc  */
    /* JADX WARNING: Removed duplicated region for block: B:83:0x01c8  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static com.bef.effectsdk.text.data.TextBitmapResult generateBitmapNormalUTF8(java.lang.String r28, com.bef.effectsdk.text.data.TextLayoutParam r29, com.bef.effectsdk.text.TextLayoutUtils.COLOR_TYPE r30) {
        /*
            r3 = 11743(0x2ddf, float:1.6455E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r3)
            r2 = r28
            boolean r1 = r2.isEmpty()
            r0 = 0
            if (r1 == 0) goto L_0x0012
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r3)
            return r0
        L_0x0012:
            android.graphics.Typeface r11 = android.graphics.Typeface.DEFAULT
            r3 = r29
            java.lang.String r0 = r3.familyName
            if (r0 == 0) goto L_0x0036
            java.lang.String r0 = r3.familyName
            boolean r0 = r0.isEmpty()
            if (r0 != 0) goto L_0x0036
            java.lang.String r0 = r3.fontPath
            if (r0 == 0) goto L_0x01ea
            java.lang.String r0 = r3.fontPath
            boolean r0 = r0.isEmpty()
            if (r0 != 0) goto L_0x01ea
            java.lang.String r1 = r3.fontPath
            java.lang.String r0 = r3.familyName
            android.graphics.Typeface r11 = com.bef.effectsdk.text.FontCache.getFromFile(r1, r0)
        L_0x0036:
            int r7 = r3.textColor
            int r5 = r3.backColor
            int r4 = r3.shadowColor
            int[] r1 = com.bef.effectsdk.text.TextLayoutUtils.AnonymousClass1.$SwitchMap$com$bef$effectsdk$text$TextLayoutUtils$COLOR_TYPE
            int r0 = r30.ordinal()
            r0 = r1[r0]
            r6 = 1
            if (r0 == r6) goto L_0x01dc
            r0 = r7 & 255(0xff, float:3.57E-43)
            int r12 = r0 << 24
            int r0 = r7 >> 8
            r1 = 16777215(0xffffff, float:2.3509886E-38)
            r0 = r0 & r1
            int r12 = r12 + r0
            r0 = r5 & 255(0xff, float:3.57E-43)
            int r7 = r0 << 24
            int r0 = r5 >> 8
            r0 = r0 & r1
            int r7 = r7 + r0
            r0 = r4 & 255(0xff, float:3.57E-43)
            int r13 = r0 << 24
            int r0 = r4 >> 8
            r0 = r0 & r1
            int r13 = r13 + r0
        L_0x0062:
            android.graphics.Paint$Style r15 = android.graphics.Paint.Style.FILL
            int r1 = r3.paintStyle
            r0 = 2
            r17 = 0
            if (r1 == 0) goto L_0x01d8
            if (r1 == r6) goto L_0x01d2
            if (r1 == r0) goto L_0x01cc
        L_0x006f:
            r14 = 0
        L_0x0070:
            android.text.Layout$Alignment r10 = android.text.Layout.Alignment.ALIGN_NORMAL
            int r1 = r3.textAlign
            if (r1 == 0) goto L_0x01c8
            if (r1 == r6) goto L_0x01c4
            if (r1 == r0) goto L_0x01c0
        L_0x007a:
            int r1 = r3.maxLine
            int r5 = r3.lineWidth
            int r9 = r3.lineWidth
            if (r5 != 0) goto L_0x01bc
            r1 = 1
            r5 = 2048(0x800, float:2.87E-42)
            r9 = 2048(0x800, float:2.87E-42)
            r16 = 0
        L_0x0089:
            r8 = 4
            if (r1 != r6) goto L_0x01b7
            int r4 = r3.lineBreakMode
            if (r4 == 0) goto L_0x01ae
            if (r4 == r6) goto L_0x01ae
            if (r4 == r0) goto L_0x01ab
            r0 = 3
            if (r4 == r0) goto L_0x01a8
            if (r4 == r8) goto L_0x01b1
            r0 = 2048(0x800, float:2.87E-42)
            r4 = 0
        L_0x009c:
            r16 = 0
        L_0x009e:
            if (r9 <= r0) goto L_0x00a2
            r9 = 2048(0x800, float:2.87E-42)
        L_0x00a2:
            if (r5 <= r0) goto L_0x00a6
            r5 = 2048(0x800, float:2.87E-42)
        L_0x00a6:
            if (r1 != 0) goto L_0x00ab
            r1 = 2147483647(0x7fffffff, float:NaN)
        L_0x00ab:
            android.text.TextPaint r8 = new android.text.TextPaint
            r8.<init>(r6)
            if (r11 == 0) goto L_0x00b5
            r8.setTypeface(r11)
        L_0x00b5:
            r8.setColor(r12)
            r8.setStyle(r15)
            r8.setStrokeWidth(r14)
            float r0 = r3.fontSize
            r8.setTextSize(r0)
            float r12 = r3.shadowRadius
            float r11 = r3.shadowDx
            float r0 = r3.shadowDy
            r8.setShadowLayer(r12, r11, r0, r13)
            float r0 = r3.letterSpacing
            r8.setLetterSpacing(r0)
            android.text.BoringLayout$Metrics r25 = android.text.BoringLayout.isBoring(r2, r8)
            if (r1 != r6) goto L_0x0152
            if (r25 == 0) goto L_0x0152
            android.text.TextUtils$TruncateAt r0 = android.text.TextUtils.TruncateAt.MARQUEE
            if (r4 == r0) goto L_0x0152
            android.text.BoringLayout r6 = new android.text.BoringLayout
            float r12 = r3.lineSpacingMult
            float r11 = r3.lineSpacingAdd
            r0 = 1
            r8 = r8
            r1 = 1
            r26 = 1
            r5 = r5
            r18 = r6
            r19 = r2
            r20 = r8
            r21 = r5
            r22 = r10
            r23 = r12
            r24 = r11
            r27 = r4
            r28 = r9
            r18.<init>(r19, r20, r21, r22, r23, r24, r25, r26, r27, r28)
        L_0x00fe:
            int r0 = r6.getLineCount()
            int r2 = java.lang.Math.min(r0, r1)
            if (r2 != 0) goto L_0x010f
            r0 = 11743(0x2ddf, float:1.6455E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)
        L_0x010d:
            r0 = 0
            return r0
        L_0x010f:
            if (r16 == 0) goto L_0x013d
        L_0x0111:
            r9 = 0
            r10 = 0
            r4 = 0
        L_0x0114:
            if (r10 >= r2) goto L_0x013f
            int r0 = r6.getLineBottom(r10)
            int r1 = java.lang.Math.max(r0, r9)
            r0 = 2048(0x800, float:2.87E-42)
            if (r1 > r0) goto L_0x013f
            float r1 = r6.getLineRight(r10)
            float r0 = r6.getLineLeft(r10)
            float r1 = r1 - r0
            int r0 = (int) r1
            int r5 = java.lang.Math.max(r0, r5)
            int r0 = r6.getLineBottom(r10)
            int r9 = java.lang.Math.max(r0, r9)
            int r4 = r4 + 1
            int r10 = r10 + 1
            goto L_0x0114
        L_0x013d:
            r5 = r9
            goto L_0x0111
        L_0x013f:
            r1 = 2048(0x800, float:2.87E-42)
            r0 = 0
            if (r5 <= r1) goto L_0x0146
            r5 = 2048(0x800, float:2.87E-42)
        L_0x0146:
            int r0 = r6.getLineBottom(r0)
            if (r0 != 0) goto L_0x01f4
            r0 = 11743(0x2ddf, float:1.6455E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)
            goto L_0x010d
        L_0x0152:
            r8 = r8
            r5 = r5
            int r6 = android.os.Build.VERSION.SDK_INT
            r0 = 23
            if (r6 < r0) goto L_0x0182
            int r6 = r2.length()
            r0 = 0
            android.text.StaticLayout$Builder r0 = android.text.StaticLayout.Builder.obtain(r2, r0, r6, r8, r5)
            android.text.StaticLayout$Builder r6 = r0.setAlignment(r10)
            float r2 = r3.lineSpacingAdd
            float r0 = r3.lineSpacingMult
            android.text.StaticLayout$Builder r2 = r6.setLineSpacing(r2, r0)
            r0 = 1
            android.text.StaticLayout$Builder r0 = r2.setIncludePad(r0)
            android.text.StaticLayout$Builder r0 = r0.setEllipsize(r4)
            android.text.StaticLayout$Builder r0 = r0.setEllipsizedWidth(r9)
            android.text.StaticLayout r6 = r0.build()
            goto L_0x00fe
        L_0x0182:
            android.text.StaticLayout r6 = new android.text.StaticLayout
            r20 = 0
            int r21 = r2.length()
            float r12 = r3.lineSpacingMult
            float r11 = r3.lineSpacingAdd
            r0 = 1
            r27 = 1
            r22 = r8
            r23 = r5
            r24 = r10
            r25 = r12
            r26 = r11
            r28 = r4
            r29 = r9
            r18 = r6
            r19 = r2
            r18.<init>(r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, r29)
            goto L_0x00fe
        L_0x01a8:
            android.text.TextUtils$TruncateAt r4 = android.text.TextUtils.TruncateAt.MIDDLE
            goto L_0x01b3
        L_0x01ab:
            android.text.TextUtils$TruncateAt r4 = android.text.TextUtils.TruncateAt.START
            goto L_0x01b3
        L_0x01ae:
            android.text.TextUtils$TruncateAt r4 = android.text.TextUtils.TruncateAt.MARQUEE
            goto L_0x01b3
        L_0x01b1:
            android.text.TextUtils$TruncateAt r4 = android.text.TextUtils.TruncateAt.END
        L_0x01b3:
            r0 = 2048(0x800, float:2.87E-42)
            goto L_0x009c
        L_0x01b7:
            r0 = 2048(0x800, float:2.87E-42)
            r4 = 0
            goto L_0x009e
        L_0x01bc:
            r16 = 1
            goto L_0x0089
        L_0x01c0:
            android.text.Layout$Alignment r10 = android.text.Layout.Alignment.ALIGN_CENTER
            goto L_0x007a
        L_0x01c4:
            android.text.Layout$Alignment r10 = android.text.Layout.Alignment.ALIGN_OPPOSITE
            goto L_0x007a
        L_0x01c8:
            android.text.Layout$Alignment r10 = android.text.Layout.Alignment.ALIGN_NORMAL
            goto L_0x007a
        L_0x01cc:
            android.graphics.Paint$Style r15 = android.graphics.Paint.Style.FILL_AND_STROKE
            float r14 = r3.strokeWidth
            goto L_0x0070
        L_0x01d2:
            android.graphics.Paint$Style r15 = android.graphics.Paint.Style.STROKE
            float r14 = r3.strokeWidth
            goto L_0x0070
        L_0x01d8:
            android.graphics.Paint$Style r15 = android.graphics.Paint.Style.FILL
            goto L_0x006f
        L_0x01dc:
            r0 = r7 & 255(0xff, float:3.57E-43)
            int r12 = r0 << 24
            r0 = r5 & 255(0xff, float:3.57E-43)
            int r7 = r0 << 24
            r0 = r4 & 255(0xff, float:3.57E-43)
            int r13 = r0 << 24
            goto L_0x0062
        L_0x01ea:
            java.lang.String r1 = r3.familyName
            int r0 = r3.fontStyle
            android.graphics.Typeface r11 = com.bef.effectsdk.text.FontCache.getFromSystem(r1, r0)
            goto L_0x0036
        L_0x01f4:
            if (r4 != 0) goto L_0x01f9
            r4 = 1
            r9 = 2048(0x800, float:2.87E-42)
        L_0x01f9:
            int r0 = r6.getLineCount()
            if (r4 != r0) goto L_0x022e
            android.graphics.Paint$FontMetrics r8 = r8.getFontMetrics()
            float r2 = r3.lineSpacingAdd
            float r3 = r3.lineSpacingMult
            float r1 = r8.descent
            float r0 = r8.ascent
            float r0 = java.lang.Math.abs(r0)
            float r1 = r1 + r0
            float r0 = r8.leading
            float r1 = r1 + r0
            float r3 = r3 * r1
            float r2 = r2 + r3
            int r0 = r4 + -1
            int r1 = r6.getLineBottom(r0)
            int r0 = r6.getLineTop(r0)
            int r1 = r1 - r0
            float r0 = (float) r1
            float r2 = r2 - r0
            int r0 = (r2 > r17 ? 1 : (r2 == r17 ? 0 : -1))
            if (r0 <= 0) goto L_0x022e
            r0 = 1056964608(0x3f000000, float:0.5)
            float r17 = r2 + r0
            float r0 = (float) r9
            float r0 = r0 + r17
            int r9 = (int) r0
        L_0x022e:
            com.bef.effectsdk.text.data.TextBitmapResult r8 = new com.bef.effectsdk.text.data.TextBitmapResult
            r8.<init>()
            r0 = 4
            r8.channel = r0
            r8.lineCount = r4
            r0 = 1
            r8.type = r0
            com.bef.effectsdk.text.data.CharLayout[] r0 = new com.bef.effectsdk.text.data.CharLayout[r4]
            r8.charLayouts = r0
            r3 = 0
        L_0x0240:
            if (r3 >= r4) goto L_0x02c2
            com.bef.effectsdk.text.data.CharLayout[] r1 = r8.charLayouts
            com.bef.effectsdk.text.data.CharLayout r0 = new com.bef.effectsdk.text.data.CharLayout
            r0.<init>()
            r1[r3] = r0
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r1 = r0[r3]
            int r0 = r6.getLineBaseline(r3)
            float r0 = (float) r0
            float r10 = (float) r9
            float r0 = r0 / r10
            r1.baseline = r0
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r2 = r0[r3]
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r1 = r0[r3]
            float r0 = r6.getLineLeft(r3)
            float r11 = (float) r5
            float r0 = r0 / r11
            r1.left = r0
            r2.pos_left = r0
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r2 = r0[r3]
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r1 = r0[r3]
            int r0 = r6.getLineTop(r3)
            float r0 = (float) r0
            float r0 = r0 / r10
            r1.top = r0
            r2.pos_top = r0
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r2 = r0[r3]
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r1 = r0[r3]
            float r0 = r6.getLineRight(r3)
            float r0 = r0 / r11
            r1.right = r0
            r2.pos_right = r0
            int r0 = r4 + -1
            if (r3 != r0) goto L_0x02af
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r2 = r0[r3]
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r1 = r0[r3]
            int r0 = r6.getLineBottom(r3)
            float r0 = (float) r0
            float r0 = r0 + r17
            float r0 = r0 / r10
            r1.bottom = r0
            r2.pos_bottom = r0
        L_0x02a5:
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r1 = r0[r3]
            r0 = -2
            r1.charCode = r0
            int r3 = r3 + 1
            goto L_0x0240
        L_0x02af:
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r2 = r0[r3]
            com.bef.effectsdk.text.data.CharLayout[] r0 = r8.charLayouts
            r1 = r0[r3]
            int r0 = r6.getLineBottom(r3)
            float r0 = (float) r0
            float r0 = r0 / r10
            r1.bottom = r0
            r2.pos_bottom = r0
            goto L_0x02a5
        L_0x02c2:
            int[] r1 = com.bef.effectsdk.text.TextLayoutUtils.AnonymousClass1.$SwitchMap$com$bef$effectsdk$text$TextLayoutUtils$COLOR_TYPE
            int r0 = r30.ordinal()
            r0 = r1[r0]
            r1 = 1
            if (r0 == r1) goto L_0x02fe
            android.graphics.Bitmap$Config r0 = android.graphics.Bitmap.Config.ARGB_8888
            android.graphics.Bitmap r4 = android.graphics.Bitmap.createBitmap(r5, r9, r0)
            r0 = 4
            r8.channel = r0
        L_0x02d6:
            r4.setPremultiplied(r1)
            android.graphics.Canvas r3 = new android.graphics.Canvas
            r3.<init>(r4)
            android.graphics.Paint r2 = new android.graphics.Paint
            r2.<init>()
            r2.setColor(r7)
            android.graphics.Rect r1 = new android.graphics.Rect
            r0 = 0
            r1.<init>(r0, r0, r5, r9)
            r3.drawRect(r1, r2)
            r6.draw(r3)
            r8.bitmap = r4
            r0 = 0
            r3.setBitmap(r0)
            r0 = 11743(0x2ddf, float:1.6455E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)
            return r8
        L_0x02fe:
            android.graphics.Bitmap$Config r0 = android.graphics.Bitmap.Config.ALPHA_8
            android.graphics.Bitmap r4 = android.graphics.Bitmap.createBitmap(r5, r9, r0)
            r8.channel = r1
            goto L_0x02d6
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bef.effectsdk.text.TextLayoutUtils.generateBitmapNormalUTF8(java.lang.String, com.bef.effectsdk.text.data.TextLayoutParam, com.bef.effectsdk.text.TextLayoutUtils$COLOR_TYPE):com.bef.effectsdk.text.data.TextBitmapResult");
    }
}
