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