java: 读取字体文件(ttf, ...)中的字体名

int i = 101;        
        
        File[] fileList = new File("E:\\fonts2").listFiles();
        for(File f:fileList)
        {
            //System.out.println(f);
            
            String fileName = f.getName();
            int index = fileName.lastIndexOf(".");            
            
            String path = "e:\\fonts\\" + i + fileName.substring(index);
            
            //System.out.println(fontName + "  --->  " + path);            
            i++;            
            
            Font f2;
            try
            {
                f2 = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(f.getAbsoluteFile()));
                String fontName = f2.getName();
                System.out.println(f.getName() + "  ---> 字体名:" + fontName);                
                
                System.err.println("hashmap_put(fontFileMap, strdup(\"" + fontName + "\"), strdup(\"" + path.replace("\\",  "\\\\") + "\"));");                
                
                //Files.copy(f.toPath(), new File(path).toPath()); //把文件复制一份到另一个文件夹               
                
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }            
        }
        
        System.exit(0);

 

参考:https://bbs.csdn.net/topics/390161351

posted @ 2020-09-17 15:28  personnel  阅读(3728)  评论(0编辑  收藏  举报
友情链接:图片批量处理工具 gif动态图制作工具 制作电子相册 图片排版工具 制作淘宝主图视频 MKScript 鼠标键盘自动化脚本语言