package com.zxhl.cms.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;

import com.zxhl.cms.R;

/**
 * @author (wangXuewei)
 * @datetime 2022-04-20 17:03 GMT+8
 * @detail :
 */
public class FontTextView extends AppCompatTextView {
    public FontTextView(@NonNull Context context) {
        super(context);
        setFont();
    }

    public FontTextView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        setFont();
    }

    public FontTextView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setFont();
    }

    private void setFont(){
        String fontPath = "fonts/zywyh.ttf";
        //设置字体
        if (!TextUtils.isEmpty(fontPath)) {
            Typeface typeFace = Typeface.createFromAsset(getContext().getAssets(), fontPath);
            setTypeface(typeFace);
        }
    }
}
