Looly 5 年 前
コミット
ac314bb14a

+ 15 - 0
hutool-core/src/test/java/cn/hutool/core/img/FontUtilTest.java

@@ -0,0 +1,15 @@
+package cn.hutool.core.img;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.awt.Font;
+
+public class FontUtilTest {
+
+	@Test
+	public void createFontTest(){
+		final Font font = FontUtil.createFont();
+		Assert.assertNotNull(font);
+	}
+}

+ 16 - 0
hutool-core/src/test/java/cn/hutool/core/img/ImgTest.java

@@ -4,6 +4,9 @@ import cn.hutool.core.io.FileUtil;
 import org.junit.Ignore;
 import org.junit.Test;
 
+import java.awt.Color;
+import java.awt.Font;
+
 public class ImgTest {
 	
 	@Test
@@ -23,4 +26,17 @@ public class ImgTest {
 	public void roundTest() {
 		Img.from(FileUtil.file("e:/pic/face.jpg")).round(0.5).write(FileUtil.file("e:/pic/face_round.png"));
 	}
+
+	@Test
+	@Ignore
+	public void pressTextTest() {
+		Img.from(FileUtil.file("d:/test/617180969474805871.jpg"))
+				.setPositionBaseCentre(false)
+				.pressText("版权所有", Color.RED, //
+						new Font("黑体", Font.BOLD, 100), //
+						0, //
+						100, //
+						1f)
+				.write(FileUtil.file("d:/test/test2_result.png"));
+	}
 }

+ 4 - 4
hutool-core/src/test/java/cn/hutool/core/img/ImgUtilTest.java

@@ -70,13 +70,13 @@ public class ImgUtilTest {
 	@Ignore
 	public void pressTextTest() {
 		ImgUtil.pressText(//
-				FileUtil.file("e:/pic/face.jpg"), //
-				FileUtil.file("e:/pic/test2_result.png"), //
-				"版权所有", Color.WHITE, //
+				FileUtil.file("d:/test/617180969474805871.jpg"), //
+				FileUtil.file("d:/test/test2_result.png"), //
+				"版权所有", Color.RED, //
 				new Font("黑体", Font.BOLD, 100), //
 				0, //
 				0, //
-				0.8f);
+				1f);
 	}
 
 	@Test