I've written this code:
List<string> fontNames开发者_Python百科 = 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.
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.
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.
精彩评论