码迷,mamicode.com
首页 > 系统相关 > 详细

linux加载字体

时间:2017-10-09 09:54:20      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:ati   ons   str   time   stat   bsp   tcl   source   register   

    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);
    }

linux加载字体

标签:ati   ons   str   time   stat   bsp   tcl   source   register   

原文地址:http://www.cnblogs.com/zhimingxin/p/7639558.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!