修改了资源路径6
This commit is contained in:
parent
7a060c442e
commit
492eef5bc0
@ -11,11 +11,8 @@ import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@ -43,7 +40,8 @@ public class CertService {
|
||||
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
|
||||
// 1. 添加证书编号
|
||||
Font font = new Font("Microsoft YaHei", Font.PLAIN, 40); // 可根据模板调整大小
|
||||
Font font = loadFont("static/cert/msyh.ttf", 40f);
|
||||
// Font font = new Font("Microsoft YaHei", Font.PLAIN, 40); // 可根据模板调整大小
|
||||
g2d.setFont(font);
|
||||
|
||||
Color customColor = Color.decode("#008983");
|
||||
@ -266,5 +264,14 @@ public class CertService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Font loadFont(String path, float size) {
|
||||
try {
|
||||
ClassPathResource resource = new ClassPathResource(path);
|
||||
try (InputStream inputStream = resource.getInputStream()) {
|
||||
return Font.createFont(Font.TRUETYPE_FONT, inputStream).deriveFont(size);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("字体加载失败: " + path, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
src/main/resources/static/cert/msyh.ttf
Normal file
BIN
src/main/resources/static/cert/msyh.ttf
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user