From fcc016d81c67710abff1bb19da6eaeadaea844e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=9A=E6=98=86?= Date: Wed, 2 Mar 2022 20:43:11 +0800 Subject: [PATCH] update fileName --- .../doric/src/main/java/pub/doric/shader/TextNode.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doric-android/doric/src/main/java/pub/doric/shader/TextNode.java b/doric-android/doric/src/main/java/pub/doric/shader/TextNode.java index 6d373e36..a3342659 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/TextNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/TextNode.java @@ -28,6 +28,7 @@ import android.text.Html; import android.text.Layout; import android.text.Spanned; import android.text.TextUtils; +import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.ViewTreeObserver; @@ -258,6 +259,7 @@ public class TextNode extends ViewNode { } } else if (prop.isObject()) { final JSObject resource = prop.asObject(); + final String identifier = resource.getProperty("identifier").asString().value(); final DoricResource doricResource = getDoricContext().getDriver().getRegistry().getResourceManager() .load(getDoricContext(), resource); if (doricResource != null) { @@ -271,7 +273,7 @@ public class TextNode extends ViewNode { } else { filePath = getContext().getFilesDir().getPath() + "/customFonts"; } - File file = createFile(fontData, filePath, "tempFont.ttf"); + File file = createFile(fontData, filePath, (identifier == null) ? "tempFont.ttf" : identifier); Typeface customFont = Typeface.createFromFile(file); view.setTypeface(customFont); } catch (Exception e) { @@ -461,6 +463,7 @@ public class TextNode extends ViewNode { if(!dir.exists()&&dir.isDirectory()){ // 判断文件目录是否存在 dir.mkdirs(); } + Log.d("font", fileName); file = new File(filePath+"\\"+fileName); fos = new FileOutputStream(file); bos = new BufferedOutputStream(fos);