1

我需要能够找到字体的完整文件名,或者只是它的完整字体名称,如 windows/fonts 文件夹中所示。

例如,如果您使用字体对话框选择 Arial,您可以选择粗体、斜体或粗斜体。返回的字体对象将仅具有名称“Arial”,但它将在字体文件夹中使用的实际字体将是“Arial Bold”,并且 .ttf 将是 Arialbd.ttf 而不是简单的 Arial.ttf

作为最终结果,我需要字体的实际文件名,但我可以使用带有全名的注册表来获取它。所以我需要能够从选定的字体中得到它。

注意:我知道可以手动将“粗体”或“斜体”附加到末尾,但并非所有字体最后都使用这些。例如,我有一种安装字体,其中斜体版本的全名不是斜体,而是以“斜体”结尾。

谢谢。

4

1 回答 1

0

I don't know the .Net way. With GDI, you can query for the OUTLINETEXTMETRICS of the selected font (assuming it's a TrueType or OpenType font). The otmFaceName field gives the full name. You can then query the registry for the file name.

If it's not a TrueType of OpenType font, then you can probably use GetTextFace and look that up in the registry. I see a few non-outline fonts in the registry, but not all of them.

There may be another way.

于 2012-08-20T18:13:33.450 回答