Reputation: 23
I need to be able to find either a font's full file name, or just it's full font name, as is shown in the windows/fonts folder.
For example if you use the Font Dialog to select Arial, you can select bold, italic or bold italic. The font object returned will simply have the name "Arial" but the actual Font it will be using from the fonts folder will be "Arial Bold" and the .ttf will be Arialbd.ttf rather than simply Arial.ttf
As an end result I need the actual file name of the font, but I can get this using the registry with the full name. So I need to be able to get this from a selected font.
Note: I know it's possible to just append "Bold" or "Italic" to the end manually, but not all fonts use these at the end. For example I have one instaled font where instead of italic the full name for the italic version of the font ends in "oblique."
Thanks.
Upvotes: 1
Views: 244
Reputation: 48021
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.
Upvotes: 0