Commit 72db687a authored by fangxinjiang's avatar fangxinjiang

自定义字体-fxj

parent 3f9308f6
...@@ -16,13 +16,14 @@ import java.util.Random; ...@@ -16,13 +16,14 @@ import java.util.Random;
public class RandomFontStyleUtil { public class RandomFontStyleUtil {
// 常见中文字体列表 // 常见中文字体列表
private static final String[] FONT_NAMES = { private static final String[] FONT_NAMES = {
"宋体", "楷体", "仿宋", "黑体", "幼圆","微软雅黑", "华文行楷","方正舒体","宋体", "楷体", "仿宋",
"隶书", "华文隶书","华文行楷", "方正舒体" "隶书", "华文隶书", "幼圆",
"Allison","Bradley Hand"
}; };
// 字体大小范围 // 字体大小范围
private static final int MIN_FONT_SIZE = 11; private static final int MIN_FONT_SIZE = 11;
private static final int MAX_FONT_SIZE = 13; private static final int MAX_FONT_SIZE = 16;
/** /**
* 为单元格设置随机字体样式 * 为单元格设置随机字体样式
...@@ -37,7 +38,6 @@ public class RandomFontStyleUtil { ...@@ -37,7 +38,6 @@ public class RandomFontStyleUtil {
// 设置随机字体 // 设置随机字体
Random random = new Random(); Random random = new Random();
font.setFontName(FONT_NAMES[random.nextInt(FONT_NAMES.length)]); font.setFontName(FONT_NAMES[random.nextInt(FONT_NAMES.length)]);
log.error("随机字体:" + font.getFontName());
// 设置随机字体大小 // 设置随机字体大小
font.setFontHeightInPoints((short) (MIN_FONT_SIZE + random.nextInt(MAX_FONT_SIZE - MIN_FONT_SIZE + 1))); font.setFontHeightInPoints((short) (MIN_FONT_SIZE + random.nextInt(MAX_FONT_SIZE - MIN_FONT_SIZE + 1)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment