Sfoglia il codice sorgente

【CHG】修改生成二维码字体

ZhaoMn 3 anni fa
parent
commit
e94f13e1fa

+ 1 - 3
railway-common/src/main/java/com/railway/common/utils/QRCodeUtilEx.java

@@ -113,7 +113,7 @@ public class QRCodeUtilEx {
     g2.clearRect(0, 0, width, height);
     g2.setPaint(Color.BLACK);
     FontRenderContext context = g2.getFontRenderContext();
-    Font font = new Font("微软雅黑", Font.BOLD, FONT_SIZE);
+    Font font = new Font("宋体", Font.BOLD, FONT_SIZE);
     g2.setFont(font);
     LineMetrics lineMetrics = font.getLineMetrics(str, context);
     FontMetrics fontMetrics = FontDesignMetrics.getMetrics(font);
@@ -121,9 +121,7 @@ public class QRCodeUtilEx {
     float y =
         (height + lineMetrics.getAscent() - lineMetrics.getDescent() - lineMetrics.getLeading())
             / 2;
-
     g2.drawString(str, (int) offset, (int) y);
-
     return textImage;
   }