我在哪里可以找到从字体的字体名称到文件名的地图? [英] Where can I find a map from font font face names to filenames?

查看:282
本文介绍了我在哪里可以找到从字体的字体名称到文件名的地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写一个Java程序,为其名字找到一个字体的TTF。例如,在我的Windows机器上输入Times New Roman会返回路径C:\ Windows \ Font \times.ttf。



其他字体名称在TTF文件的名称中以类似的方式缩写。有没有一个标准的地方,我可以使用它来映射字体的名称到相应的TTF文件名可预测? 解决方案

记住的名称字体是在文件的内容中定义的,所以没有理由与字体文件本身的名称有任何关系。

在Windows XP中,注册表项 HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Fonts 列出所有永久安装的系统字体。你可以枚举这个字体文件列表,依次打开每个字体文件,如果是ttf,你可以从获取 checkSumAdjustment c $ c>表。构建一个项目列表,每个项目包含一对值 - 字体文件名和校验和值。

然后,当您稍后意识到字体时,请调用 GetFontData 并读取表并找到 checkSumAdjustment 字体。然后在你之前做的列表中查看。


I'm trying to write a Java program that finds the TTF for a font face given its name. For example, inputting "Times New Roman" on my Windows machine would return the path "C:\Windows\Fonts\times.ttf".

Most other font face names are abbreviated in a similar manner in the name of their TTF file. Is there a standard somewhere that I can use to map font face names to corresponding TTF filenames predictably?

解决方案

Remember the name of the font is defined within the contents of the file, so there's no reason there should be any relation with the name of the font file itself.

In Windows XP the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts lists all the permanent installed system fonts. You can enumerate this list of font files, opening each one in turn and if it is a ttf you can get the checkSumAdjustment from its head table. Build a list of items, each item containing a pair of values - the font file name and the checksum value.

Then when you later realize a font, call GetFontData on it and read the head table and find the checkSumAdjustment for that font. Then look it up in the list you made earlier.

这篇关于我在哪里可以找到从字体的字体名称到文件名的地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆