Skip to content

Commit

Permalink
3.2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Jan 6, 2025
1 parent 46f2f7f commit 55daf73
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ androidCompileSdk = "35"

jvmTarget = "17"

libVersion = "3.2.7"
libVersion = "3.2.8"

kotlin = "2.1.0"
agp = "8.7.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
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;
import android.text.StaticLayout;
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;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 55daf73

Please sign in to comment.