From 55daf7314948e0f5072c3068fb8c36424d5fdf78 Mon Sep 17 00:00:00 2001 From: T8RIN Date: Mon, 6 Jan 2025 10:24:20 +0300 Subject: [PATCH] 3.2.8 --- gradle/libs.versions.toml | 2 +- .../com/watermark/androidwm/bean/WatermarkText.java | 13 ++++++------- .../com/watermark/androidwm/utils/BitmapUtils.java | 8 ++------ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9e5b0b50..d643193c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ androidCompileSdk = "35" jvmTarget = "17" -libVersion = "3.2.7" +libVersion = "3.2.8" kotlin = "2.1.0" agp = "8.7.3" diff --git a/libs/androidwm/src/main/java/com/watermark/androidwm/bean/WatermarkText.java b/libs/androidwm/src/main/java/com/watermark/androidwm/bean/WatermarkText.java index 1adf9206..e41ca068 100644 --- a/libs/androidwm/src/main/java/com/watermark/androidwm/bean/WatermarkText.java +++ b/libs/androidwm/src/main/java/com/watermark/androidwm/bean/WatermarkText.java @@ -19,11 +19,11 @@ import android.graphics.Color; import android.graphics.Paint; +import android.graphics.Typeface; import android.widget.EditText; import android.widget.TextView; import androidx.annotation.ColorInt; -import androidx.annotation.FontRes; /** * It's a wrapper of the watermark text. @@ -41,8 +41,7 @@ public class WatermarkText { @ColorInt private int backgroundColor = Color.TRANSPARENT; private Paint.Style style = Paint.Style.FILL; - @FontRes - private int typeFaceId = 0; + private Typeface typeface = null; private float textShadowBlurRadius; private float textShadowXOffset; private float textShadowYOffset; @@ -154,15 +153,15 @@ public int getTextShadowColor() { return textShadowColor; } - public int getTextFont() { - return typeFaceId; + public Typeface getTextTypeface() { + return typeface; } /** * Use the typeface path to get the text typeface. */ - public WatermarkText setTextFont(@FontRes int typeFaceId) { - this.typeFaceId = typeFaceId; + public WatermarkText setTextTypeface(Typeface typeface) { + this.typeface = typeface; return this; } diff --git a/libs/androidwm/src/main/java/com/watermark/androidwm/utils/BitmapUtils.java b/libs/androidwm/src/main/java/com/watermark/androidwm/utils/BitmapUtils.java index 8002500b..e8dab785 100644 --- a/libs/androidwm/src/main/java/com/watermark/androidwm/utils/BitmapUtils.java +++ b/libs/androidwm/src/main/java/com/watermark/androidwm/utils/BitmapUtils.java @@ -25,7 +25,6 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Rect; -import android.graphics.Typeface; import android.os.Build; import android.os.Environment; import android.text.Layout; @@ -33,8 +32,6 @@ import android.text.TextPaint; import android.util.Base64; -import androidx.core.content.res.ResourcesCompat; - import com.watermark.androidwm.bean.WatermarkImage; import com.watermark.androidwm.bean.WatermarkText; @@ -77,9 +74,8 @@ public static Bitmap textAsBitmap(Context context, WatermarkText watermarkText, watermarkText.getTextShadowColor()); } - if (watermarkText.getTextFont() != 0) { - Typeface typeface = ResourcesCompat.getFont(context, watermarkText.getTextFont()); - watermarkPaint.setTypeface(typeface); + if (watermarkText.getTextTypeface() != null) { + watermarkPaint.setTypeface(watermarkText.getTextTypeface()); } watermarkPaint.setAntiAlias(true);