You've already forked FrameTour-BE
feat(watermark): 调整水印默认字体及位置参数
- 更改默认字体文件路径为 "/PingFang_SC_t.ttf" -修正字体资源加载类为 PrinterDefaultWatermarkOperator - 调整垂直偏移量 OFFSET_Y 从20 到15 - 微调二维码左边距比例从0.07 到 0.075 - 修改二维码垂直偏移量 QRCODE_OFFSET_Y从 -20 到 -35 - 设置景区名称和时间字体样式为粗体 (BOLD)
This commit is contained in:
@@ -17,13 +17,13 @@ import java.io.InputStream;
|
||||
|
||||
@Slf4j
|
||||
public class PrinterDefaultWatermarkOperator implements IOperator {
|
||||
private static final String FONT_PATH = "/PingFang_SC.ttf";
|
||||
private static final String FONT_PATH = "/PingFang_SC_t.ttf";
|
||||
public static String defaultFontName;
|
||||
public static float FONT_GLOBAL_OFFSET_PERCENT = 0;
|
||||
static {
|
||||
try {
|
||||
// 加载字体文件流
|
||||
InputStream fontStream = LeicaWatermarkOperator.class.getResourceAsStream(FONT_PATH);
|
||||
InputStream fontStream = PrinterDefaultWatermarkOperator.class.getResourceAsStream(FONT_PATH);
|
||||
if (fontStream == null) {
|
||||
throw new RuntimeException("字体文件未找到!路径:" + FONT_PATH);
|
||||
}
|
||||
@@ -44,11 +44,11 @@ public class PrinterDefaultWatermarkOperator implements IOperator {
|
||||
}
|
||||
}
|
||||
public static int EXTRA_BORDER_PX = 0;
|
||||
public static int OFFSET_Y = 20;
|
||||
public static int OFFSET_Y = 15;
|
||||
public static Color BG_COLOR = Color.WHITE;
|
||||
public static int QRCODE_SIZE = 150;
|
||||
public static double QRCODE_LEFT_MARGIN_RATIO = 0.07; // 二维码距离左边缘的图片宽度比例
|
||||
public static int QRCODE_OFFSET_Y = -20;
|
||||
public static double QRCODE_LEFT_MARGIN_RATIO = 0.075; // 二维码距离左边缘的图片宽度比例
|
||||
public static int QRCODE_OFFSET_Y = -35;
|
||||
|
||||
public static int SCENIC_FONT_SIZE = 42;
|
||||
public static Color scenicColor = Color.white;
|
||||
@@ -83,8 +83,8 @@ public class PrinterDefaultWatermarkOperator implements IOperator {
|
||||
g2d.drawImage(baseImage, EXTRA_BORDER_PX, EXTRA_BORDER_PX, null);
|
||||
int newQrcodeHeight = QRCODE_SIZE;
|
||||
int newQrcodeWidth = (int) (newQrcodeHeight * 1.0 / qrcodeImage.getHeight() * qrcodeImage.getWidth());
|
||||
Font scenicFont = new Font(defaultFontName, Font.PLAIN, SCENIC_FONT_SIZE);
|
||||
Font datetimeFont = new Font(defaultFontName, Font.PLAIN, DATETIME_FONT_SIZE);
|
||||
Font scenicFont = new Font(defaultFontName, Font.BOLD, SCENIC_FONT_SIZE);
|
||||
Font datetimeFont = new Font(defaultFontName, Font.BOLD, DATETIME_FONT_SIZE);
|
||||
FontMetrics scenicFontMetrics = g2d.getFontMetrics(scenicFont);
|
||||
FontMetrics datetimeFontMetrics = g2d.getFontMetrics(datetimeFont);
|
||||
int scenicLineHeight = scenicFontMetrics.getHeight();
|
||||
|
||||
BIN
src/main/resources/PingFang_SC_t.ttf
Normal file
BIN
src/main/resources/PingFang_SC_t.ttf
Normal file
Binary file not shown.
Reference in New Issue
Block a user