add android icon font support

This commit is contained in:
王劲鹏
2020-03-13 14:22:46 +08:00
committed by osborn
parent 4359eec700
commit 73c0a5e7ab
10 changed files with 50 additions and 2 deletions

View File

@@ -20,11 +20,11 @@ import android.util.TypedValue;
import android.view.Gravity;
import android.widget.TextView;
import com.github.pengfeizhou.jscore.JSValue;
import pub.doric.DoricContext;
import pub.doric.extension.bridge.DoricPlugin;
import com.github.pengfeizhou.jscore.JSValue;
/**
* @Description: widget
* @Author: pengfei.zhou
@@ -76,6 +76,17 @@ public class TextNode extends ViewNode<TextView> {
} else {
view.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
}
break;
case "font":
String font = prop.asString().toString();
if (font.endsWith(".ttf")) {
Typeface iconFont = Typeface.createFromAsset(getContext().getAssets(), font);
view.setTypeface(iconFont);
} else {
Typeface iconFont = Typeface.createFromAsset(getContext().getAssets(), font + ".ttf");
view.setTypeface(iconFont);
}
break;
default:
super.blend(view, name, prop);