package com.example.app;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.text.TextPaint;
import android.util.TypedValue;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import static com.example.app.DensityUtil.dip2px;


/**
 * widget factory
 */
public class WidgetTextFactory {

    private Context mContext;

    private int mDefaultMinTextSize = 14;
    private int mMaxViewSize;

    public WidgetTextFactory(Context context) {
        mContext = context.getApplicationContext();
        mMaxViewSize = (DensityUtil.getScreenWidth(context) - dip2px(context, 20 + 20 + 16)) / 2 - 20;
    }

    public ArrayList<WidgetTextBean> getAllFonts() {
        ArrayList<WidgetTextBean> result = new ArrayList<>();
        result.add(getFontWow());
        result.add(getFontBless());
        result.add(getFontSlay());
        result.add(getFontYes());
        result.add(getFontSnatched());
        result.add(getFontHi());
        result.add(getFontTitle1());
        result.add(getFontTitle2());
        result.add(getFontSubTitle1());
        result.add(getFontSubTitle2());
        result.add(getFontDay());
        result.add(getFontHmmm());
        result.add(getFontNoooo());
        result.add(getFontWhat());
        result.add(getFontNetflix());
        result.add(getFontGiveLife());
        result.add(getFontMyBea());
        result.add(getFontWhatAday());
        result.add(getFontLit());
        result.add(getFontThis());
        return result;
    }

    private WidgetTextBean getFontWow() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(32);
        WidgetTextBean.setTypeface("wow.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 120));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 105));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("WOW!");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.edit_font_fed847), mContext.getResources().getColor(R.color.edit_font_fca03a)});
        WidgetTextBean.setBackgroundRes(R.drawable.edit_font_bg_wow);
//        WidgetTextBean.setTextRect(new Rect((342 - 290) / 2 - 10, (306 - 140) / 2, (342 - 150) / 2 + 230, (306 - 110) / 2 + 90));
        int textRectTop = (dip2px(mContext, 105) - getMaxTextRectHeight("wow.ttf", 2)) / 2 + dip2px(mContext, 3);
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 2), textRectTop, dip2px(mContext, 120 - 2), dip2px(mContext, 105) - textRectTop));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(-5);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 3f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(android.R.color.black)});
        WidgetTextBean.setTextStrokeGradient(WidgetTextBean.COLOR_GRADIENT_VERTICAL);
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, -13));
        return WidgetTextBean;
    }

    private WidgetTextBean getFontBless() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(28);
        WidgetTextBean.setTypeface("blessed.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 140));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 100));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("BLESSED");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.bless_font_color)});
        WidgetTextBean.setBackgroundRes(R.drawable.edit_font_bg_blessed);
        int textRectTop = (dip2px(mContext, 100) - getMaxTextRectHeight("blessed.ttf", 2)) / 2 + dip2px(mContext, 2);
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 5), textRectTop, dip2px(mContext, 140 - 5), dip2px(mContext, 100) - textRectTop));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 2f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(android.R.color.white)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setLineSpace(20);
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 2));
        return WidgetTextBean;
    }

    public WidgetTextBean getFontHi() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(20);
        WidgetTextBean.setTypeface("hi.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 103 + 10));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 54));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("Hi!There");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.hi_font_color)});
        WidgetTextBean.setBackgroundRes(R.drawable.edit_font_bg_hi);
        int textRextTop = (dip2px(mContext, 54) - getMaxTextRectHeight("hi.ttf", 2)) / 2 + dip2px(mContext, 8);
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 5), textRextTop, dip2px(mContext, 103), dip2px(mContext, 54 - 4) - textRextTop));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(android.R.color.white)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setLineSpace(-10);
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, -4));
        return WidgetTextBean;
    }


    public WidgetTextBean getFontDay() {
        final WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(55);
        WidgetTextBean.setTypeface("day.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 92));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 110));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        WidgetTextBean.setText(calendar.get(Calendar.DAY_OF_MONTH) + "");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.day_font_color)});
        String month = "";
        switch (calendar.get(Calendar.MONTH)) {
            case Calendar.JANUARY:
                month = "JAN";
                break;
            case Calendar.FEBRUARY:
                month = "FEB";
                break;
            case Calendar.MARCH:
                month = "MAR";
                break;
            case Calendar.APRIL:
                month = "APR";
                break;
            case Calendar.MAY:
                month = "MAY";
                break;
            case Calendar.JUNE:
                month = "JUN";
                break;
            case Calendar.JULY:
                month = "JUL";
                break;
            case Calendar.AUGUST:
                month = "AUG";
                break;
            case Calendar.SEPTEMBER:
                month = "SEP";
                break;
            case Calendar.OCTOBER:
                month = "OCT";
                break;
            case Calendar.NOVEMBER:
                month = "NOV";
                break;
            case Calendar.DECEMBER:
                month = "DEC";
                break;
            default:
                break;
        }

        final TextPaint textPaint = new TextPaint();
        textPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 25, mContext.getResources().getDisplayMetrics()));
        textPaint.setColor(mContext.getResources().getColor(R.color.day_font_color));
        textPaint.setFakeBoldText(true);
        textPaint.setTypeface(Typeface.createFromAsset(mContext.getAssets(), "day.ttf"));
        textPaint.setDither(true);
        textPaint.setAntiAlias(true);
        textPaint.setFilterBitmap(true);

        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(10);
        paint.setColor(mContext.getResources().getColor(R.color.day_font_color));

        Bitmap bitmap = Bitmap.createBitmap(dip2px(mContext, 92), dip2px(mContext, 110), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        int x = (int) ((dip2px(mContext, 92) - textPaint.measureText(month)) / 2);
        canvas.drawText(month, x, dip2px(mContext, 14 + 20), textPaint);
        canvas.drawRect(new RectF(0, 0, dip2px(mContext, 92), dip2px(mContext, 110)), paint);
        WidgetTextBean.setBackgroundDrawable(new BitmapDrawable(mContext.getResources(), bitmap));

        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 14), dip2px(mContext, 34), dip2px(mContext, 92 - 14), dip2px(mContext, 110 - 34)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_HORIZONTAL_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.day_font_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        WidgetTextBean.setEditable(false);
        return WidgetTextBean;
    }


    private WidgetTextBean getFontHmmm() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(30);
        WidgetTextBean.setTypeface("hmmm.ttf");
        WidgetTextBean.setDefaultWidth(mMaxViewSize);
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 60));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("HMMM..");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.hmmm_font_color)});
        WidgetTextBean.setTextRect(new Rect(10, 0, mMaxViewSize - 10, dip2px(mContext, 60)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 1.3f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(android.R.color.black)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0f));
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }

    public WidgetTextBean getFontNoooo() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(26);
        WidgetTextBean.setTypeface("noooo.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 130));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 60));
        WidgetTextBean.setImageRes(R.drawable.edit_font_noooo_line);
        WidgetTextBean.setImageWidth(dip2px(mContext, 107));
        WidgetTextBean.setImageHeight(dip2px(mContext, 12));
        WidgetTextBean.setText("Nooo!!!");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.noooo_font_color)});
        WidgetTextBean.setTextRect(new Rect(0, 0, dip2px(mContext, 130), dip2px(mContext, 60 - 12 - 6 - 5)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setImageX(dip2px(mContext, 2));
        WidgetTextBean.setImageY(dip2px(mContext, 60 - 12 - 6 - 5));
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setLineSpace(24);
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }

    private WidgetTextBean getFontSlay() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(32);
        WidgetTextBean.setTypeface("slay.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 99));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 99));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("SLAY");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.slay_font_color)});
        WidgetTextBean.setBackgroundRes(R.drawable.edit_font_bg_postface);
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 5), dip2px(mContext, 20), dip2px(mContext, 99 - 5), dip2px(mContext, 99 - 20)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(android.R.color.white)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setLineSpace(15);
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, -2));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }


    private WidgetTextBean getFontYes() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(40);
        WidgetTextBean.setTypeface("yes.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 103));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 80));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("YES!");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.yes_font_color)});
        WidgetTextBean.setBackgroundRes(R.drawable.edit_font_bg_yes);
        int maxTextRectTop = (dip2px(mContext, 80) - getMaxTextRectHeight("yes.ttf", 2)) / 2 + 10;
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 15), maxTextRectTop, dip2px(mContext, 103 - 15), dip2px(mContext, 80) - maxTextRectTop));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.yes_font_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }

    private WidgetTextBean getFontTitle1() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(20);
        WidgetTextBean.setTypeface("title1.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 141));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 52));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("I'M TITLE");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.title1_font_color)});
        WidgetTextBean.setBackgroundRes(R.drawable.edit_font_bg_title);
        int textRectTop = (dip2px(mContext, 52) - getMaxTextRectHeight("title1.ttf", 2)) / 2 + dip2px(mContext, 6);
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 16), textRectTop, dip2px(mContext, 141 - 16), dip2px(mContext, 52) - textRectTop));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(android.R.color.white)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 1));
        return WidgetTextBean;
    }


    private WidgetTextBean getFontTitle2() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(18);
        WidgetTextBean.setTypeface("title2.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 103));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 103));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("I'm\ntitle");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.title2_font_color)});
        WidgetTextBean.setBackgroundRes(R.drawable.edit_font_bg_titile2);
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 20), dip2px(mContext, 25), dip2px(mContext, 102 - 20), dip2px(mContext, 102 - 25)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(12);
        WidgetTextBean.setTextRotateAngle(0);
//        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.empty_font_stroke_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setLineSpace(dip2px(mContext, 6));
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }


    private WidgetTextBean getFontWhat() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(36);
        WidgetTextBean.setTypeface("what.ttf");
        WidgetTextBean.setDefaultWidth(mMaxViewSize);
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 50));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("WHAT?");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.what_font_color)});
        WidgetTextBean.setTextRect(new Rect(0, 0, mMaxViewSize, dip2px(mContext, 50)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.empty_font_stroke_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setLineSpace(30);
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }

    private WidgetTextBean getFontNetflix() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(32);
        WidgetTextBean.setTypeface("netflix.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 120));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 130));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("Netflix\nand\nchill...");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.netflix_font_color)});
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 5), dip2px(mContext, 10), dip2px(mContext, 120 - 5), dip2px(mContext, 120)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_VERTICAL_CENTER);
        WidgetTextBean.setMinTextSize(10);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0.3f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.netflix_font_stroke_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }

    private WidgetTextBean getFontLit() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(28);
        WidgetTextBean.setTypeface("lit.ttf");
        WidgetTextBean.setDefaultWidth(mMaxViewSize);
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 42));
        WidgetTextBean.setImageX(dip2px(mContext, 22));
        WidgetTextBean.setImageY(dip2px(mContext, 0));
        WidgetTextBean.setImageRes(R.drawable.edit_font_bg_lit);
        WidgetTextBean.setImageWidth(dip2px(mContext, 41));
        WidgetTextBean.setImageHeight(dip2px(mContext, 42));
        WidgetTextBean.setText("LIT");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.lit_font_color)});
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 41 + 22 + 10), dip2px(mContext, -5), mMaxViewSize - 20, dip2px(mContext, 42)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_DEFAULT);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 2f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.lit_font_stroke_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 1f));
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }


    private WidgetTextBean getFontGiveLife() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(22);
        WidgetTextBean.setTypeface("givelife.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 110));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 120));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("Giving\nMe\nLife ");
        WidgetTextBean.setTextColorGradient(WidgetTextBean.COLOR_GRADIENT_HORIZONTAL);
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.give_me_life_font_color)});
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 5), dip2px(mContext, 5), dip2px(mContext, 110 - 5), dip2px(mContext, 120 - 5)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setTextStrokeGradient(WidgetTextBean.COLOR_GRADIENT_HORIZONTAL);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 1.3f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.give_me_life_start_font_stroke_color), mContext.getResources().getColor(R.color.give_me_life_end_font_stroke_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setLineSpace(30);
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 3));
        return WidgetTextBean;
    }

    private WidgetTextBean getFontSubTitle1() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(18);
        WidgetTextBean.setTypeface("roboto.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 152));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 36));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("I'm subtitles 1");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.subtitle1_font_color)});
        WidgetTextBean.setBackgroundRes(R.drawable.edit_font_bg_subtitle1);
        int textRextTop = (dip2px(mContext, 36) - getMaxTextRectHeight(null, 2)) / 2 + dip2px(mContext, 9);
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 2), textRextTop, dip2px(mContext, 152 - 2), dip2px(mContext, 36 - 0) - textRextTop));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
//        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.empty_font_stroke_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0f));
        if (DensityUtil.isHighDpi(mContext)) {
            WidgetTextBean.setLineSpace(10);
        } else {
            WidgetTextBean.setLineSpace(-10);
        }
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 2));
        return WidgetTextBean;
    }

    private WidgetTextBean getFontSubTitle2() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(18);
        WidgetTextBean.setTypeface("subtitle2.ttf");
        WidgetTextBean.setDefaultWidth(dip2px(mContext, 152));
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 36));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("I'm subtitles 2");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.subtitle2_font_color)});
        WidgetTextBean.setBackgroundRes(R.drawable.edit_font_bg_subtitle2);
        int textRextTop = (dip2px(mContext, 36) - getMaxTextRectHeight("subtitle2.ttf", 2)) / 2 + dip2px(mContext, 9);
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 2), textRextTop, dip2px(mContext, 152 - 2), dip2px(mContext, 36 - 0) - textRextTop));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
//        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0.3f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.empty_font_stroke_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        if (DensityUtil.isHighDpi(mContext)) {
            WidgetTextBean.setLineSpace(10);
        } else {
            WidgetTextBean.setLineSpace(-10);
        }
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 2));
        return WidgetTextBean;
    }

    private WidgetTextBean getFontSnatched() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(28);
        WidgetTextBean.setTypeface("snatch.ttf");
        WidgetTextBean.setDefaultWidth(mMaxViewSize);
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 100));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("SNATCHED");
        WidgetTextBean.setTextColorGradient(WidgetTextBean.COLOR_GRADIENT_HORIZONTAL);
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.snatch_start_font_color), mContext.getResources().getColor(R.color.snatch_end_font_color)});
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 0), dip2px(mContext, 10), mMaxViewSize - dip2px(mContext, 0), dip2px(mContext, 100 - 10)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 0f));
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }


    private WidgetTextBean getFontWhatAday() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(28);
        WidgetTextBean.setTypeface("whatday.ttf");
        WidgetTextBean.setDefaultWidth(mMaxViewSize);
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 100));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("WHAT A ... DAY");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.what_a_day_font_color)});
        WidgetTextBean.setTextRect(new Rect(0, dip2px(mContext, 10), mMaxViewSize, dip2px(mContext, 100 - 10)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 1f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.what_a_day_font_stroke_color)});
        WidgetTextBean.setLetterSpace(-1.5f);
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }

    private WidgetTextBean getFontMyBea() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        WidgetTextBean.setTextSize(26);
        WidgetTextBean.setTypeface("mybea.ttf");
        WidgetTextBean.setDefaultWidth(mMaxViewSize);
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 50));
        WidgetTextBean.setImageX(0);
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setText("My Bae");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.mybea_font_color)});
        WidgetTextBean.setBackgroundRes(R.drawable.edit_font_bg_mybea);
        int textRextTop = (dip2px(mContext, 50) - getMaxTextRectHeight("mybea.ttf", 2)) / 2;
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 23), textRextTop, mMaxViewSize - dip2px(mContext, 23), dip2px(mContext, 50) - textRextTop));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 2f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.mybea_font_stroke_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0f));
        WidgetTextBean.setLineSpace(20);
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 5));
        return WidgetTextBean;
    }

    private WidgetTextBean getFontThis() {
        WidgetTextBean WidgetTextBean = new WidgetTextBean();
        if (DensityUtil.isHighDpi(mContext)) {
            WidgetTextBean.setTextSize(28);
        } else {
            WidgetTextBean.setTextSize(25);
        }
        WidgetTextBean.setTypeface("this.ttf");
        WidgetTextBean.setDefaultWidth(mMaxViewSize);
        WidgetTextBean.setDefaultHeight(dip2px(mContext, 100));
        WidgetTextBean.setImageX(mMaxViewSize - dip2px(mContext, 25) - dip2px(mContext, 44));
        WidgetTextBean.setImageY(0);
        WidgetTextBean.setImageRes(R.drawable.edit_font_bg_this);
        WidgetTextBean.setImageWidth(dip2px(mContext, 44));
        WidgetTextBean.setImageHeight(dip2px(mContext, 39));
        WidgetTextBean.setText("This is ..");
        WidgetTextBean.setTextColor(new int[]{mContext.getResources().getColor(R.color.this_font_color)});
        WidgetTextBean.setTextRect(new Rect(dip2px(mContext, 8), dip2px(mContext, 7 + 39), mMaxViewSize - dip2px(mContext, 8), dip2px(mContext, 100)));
        WidgetTextBean.setTextGravity(WidgetTextBean.GRAVITY_HORIZONTAL_CENTER);
        WidgetTextBean.setMinTextSize(mDefaultMinTextSize);
        WidgetTextBean.setTextRotateAngle(0);
        WidgetTextBean.setStrokeWidth(dip2px(mContext, 1f));
        WidgetTextBean.setStrokeColor(new int[]{mContext.getResources().getColor(R.color.this_font_stroke_color)});
        WidgetTextBean.setLetterSpace(dip2px(mContext, 0));
        WidgetTextBean.setLineSpace(30);
        WidgetTextBean.setTextStartXOffset(dip2px(mContext, 0));
        WidgetTextBean.setTextStartYOffset(dip2px(mContext, 0));
        return WidgetTextBean;
    }


    /**
     * get the height which limited line count
     *
     * @param typeface
     * @param maxLineCount
     * @return
     */
    private int getMaxTextRectHeight(String typeface, int maxLineCount) {
        TextPaint textPaint = new TextPaint();
        textPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mDefaultMinTextSize, mContext.getResources().getDisplayMetrics()));
        if (typeface != null) {
            textPaint.setTypeface(Typeface.createFromAsset(mContext.getAssets(), typeface));
        }
        Paint.FontMetrics fontMetrics = textPaint.getFontMetrics();
        int textHeight = (int) Math.ceil(fontMetrics.bottom - fontMetrics.top);
        return textHeight * maxLineCount + (int) (textHeight * 0.9f) * (maxLineCount - 1);
    }

}