Browse Source

验证码图片自定义字体

andy 1 year ago
parent
commit
17cbf976e9
1 changed files with 3 additions and 3 deletions
  1. 3 3
      mainFactory/src/main/java/org/bfkj/utils/GenerateImage.java

+ 3 - 3
mainFactory/src/main/java/org/bfkj/utils/GenerateImage.java

@@ -17,8 +17,8 @@ import java.util.Map;
 public class GenerateImage {
     private static final int WIDTH = 120; // 图片宽度
     private static final int HEIGHT = 45; // 图片高度
-    private static String IMAGE_FORMAT = "JPG";
-    private static Color[] COLORS = new Color[]{
+    private static final String IMAGE_FORMAT = "JPG";
+    private static final Color[] COLORS = new Color[]{
             new Color(0, 0, 255),
             new Color(0, 255, 0),
             new Color(255, 0, 0)
@@ -57,7 +57,7 @@ public class GenerateImage {
             File fontFile = new ClassPathResource("font/SourceHanSansSC-Regular-2.otf").getFile();
             font = Font.createFont(Font.TRUETYPE_FONT, fontFile);
         }
-        font.deriveFont((float) (HEIGHT - 10));
+        font  = font.deriveFont((float) (HEIGHT - 10));
         graphics.setFont(font);
 
         int desX, desY, distance = 16;