static {
try {
registerNewFont(PatentsConstants.PDF_FONT_PATH + "arialuni.ttf");
registerNewFont(PatentsConstants.PDF_FONT_PATH + "simsun.ttc");
registerNewFont(PatentsConstants.PDF_FONT_PATH + "simsun_bold.ttf");
registerNewFont(PatentsConstants.MY_PDF_FONT_PATH + "MSYH.TTF");
registerNewFont(PatentsConstants.MY_PDF_FONT_PATH + "MSYHBD.TTF");
registerNewFont(PatentsConstants.MY_PDF_FONT_PATH + "SIMHEI.TTF");
registerNewFont(PatentsConstants.MY_PDF_FONT_PATH + "SIMHEIBD.TTF");
registerNewFont(PatentsConstants.MY_PDF_FONT_PATH + "ARIALBI.TTF");
registerNewFont(PatentsConstants.MY_PDF_FONT_PATH + "TIMESBI.TTF");
} catch (Exception e) {
}
}
private static void registerNewFont(String path) throws Exception {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// 读取resource中的字体
InputStream in = Object.class.getClassLoader().getResourceAsStream(path);
// 创建字体
Font newFont = Font.createFont(Font.TRUETYPE_FONT, in);
in.close();
// 注册字体
ge.registerFont(newFont);
}