如何获取字体文件名?
我编写了这段代码:
List<string> fontNames = new List<string>();
foreach (FontFamily font in FontFamily.Families)
{
fontNames.Add(font.Name);
}
获取字体名称,但是假设您想将字体复制到另一个文件夹,我将如何获取字体的文件名以便执行复制操作?
谢谢。
I've written this code:
List<string> fontNames = new List<string>();
foreach (FontFamily font in FontFamily.Families)
{
fontNames.Add(font.Name);
}
to get fonts name, but lets say if you want to copy the font to another folder, how would I get the font's file name in order to do the copy operation?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你能够访问注册表,那么你可以从键中获取文件名:'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts',基本上每个字体文件都放在C:\Windows\Fonts中,除非别处提到。
If you're able to access the registry, so you could get the file name out of the Key: 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', basically every font file is placed in C:\Windows\Fonts, unless mentioned elsewhere.
CP 有一个 C++ 解决方案,用于 从
HFONT
GDI+ 字体句柄。您可以首先使用
Font.ToHfont()
方法获取字体句柄,然后使用CP文章中提到的代码。当然,这需要使用一些 PInvoke 将 C++ 代码重写为 C#。There is a C++ solution over at CP for getting a filename from a
HFONT
GDI+ font handle.You could first use the
Font.ToHfont()
method to get the font handle and then use the code in the mentioned CP article. Of course this would require to rewrite the C++ code to C# with some PInvoke's.