From f2d0791b8bc23bb6dcd62aca81eda94330e42af1 Mon Sep 17 00:00:00 2001 From: Looly Date: Mon, 12 Aug 2024 18:49:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DGraphicsUtil.drawString?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=AD=BE=E5=90=8D=E5=8F=98=E5=8C=96=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../java/cn/hutool/core/img/GraphicsUtil.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b799da02..0d27dc175 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### 🐞Bug修复 * 【extra 】 修复JakartaMailUtil引用javax的问题 +* 【core 】 修复GraphicsUtil.drawString方法签名变化导致的问题(issue#3694@Github) ------------------------------------------------------------------------------------------------------------- # 5.8.30(2024-08-09) diff --git a/hutool-core/src/main/java/cn/hutool/core/img/GraphicsUtil.java b/hutool-core/src/main/java/cn/hutool/core/img/GraphicsUtil.java index 95e1349f6..5b24bcdf9 100755 --- a/hutool-core/src/main/java/cn/hutool/core/img/GraphicsUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/img/GraphicsUtil.java @@ -118,6 +118,22 @@ public class GraphicsUtil { return drawString(g, str, font, null, width, height, backgroundColor, ColorUtil.maxDistance(backgroundColor) / 2); } + /** + * 绘制字符串,默认抗锯齿 + * + * @param g {@link Graphics}画笔 + * @param str 字符串 + * @param font 字体 + * @param color 字体颜色,{@code null} 表示使用随机颜色(每个字符单独随机) + * @param width 字符串背景的宽度 + * @param height 字符串背景的高度 + * @return 画笔对象 + * @since 4.5.10 + */ + public static Graphics drawString(Graphics g, String str, Font font, Color color, int width, int height) { + return drawString(g, str, font, color, width, height, null, 0); + } + /** * 绘制字符串,默认抗锯齿 *