Click here to Skip to main content
15,886,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a requirement wherein I have to check whether a given font file is already installed or not. From the font file, I have extracted the "Font Name", "Font Family Name" and "Post Script Name". In windows, I have to check for the registry entries in SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts. But I have noticed that for some fonts the registry entries have "Font Name" and for some (especially Adobe Fonts) have "Post Script Name".
For example, comic.ttf has "Font Name" "Comic Sans MS" and "Post Script Name" "ComicSansMs". The registry value is for "Comic Sans MS".
But for some other fonts, like MinionPro-Regular.otf(which is an adobe file), the "Font Name" is "Minion Pro" the "Post Script Name" is "MinionPro-Regular" and the registry value is for "MinionPro-Regular".

What is the the thumb rule governing the Font lookup? Does it vary from font type to font type?

Any help will be deeply appreciated.

Thanks And Regards
Posted

If you have the name of the font file, then you could just perform a quick check against the C:\Windows\Fonts directory and see if the file already exists there.
If I remember correctly, any font file placed in this folder will automatically get added to the registry so it is a valid way to check if the font is installed.
However, if you need to use the registry, you might find the EnumFontFamiliesEx[^] interface helpful.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Feb-13 19:55pm    
About the directory: this is not really so, probably it was the case with older Windows versions, as far as I could remember them. Now it requires some installation, and the procedure can be easily found in documentation.

But of course, with the registry data, you can solve the problem like this, in principle. However, it's not a maintainable approach. OP can use EnumFontFamiliesEx and related Windows API.
—SA
Sergey Alexandrovich Kryukov 20-Feb-13 19:57pm    
So, I basically answered, please see.
—SA
You need to use the Windows API EnumFontFamiliesEx and other related "Font and Text Functions". Please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd162620%28v=vs.85%29.aspx[^].

Some code sample:
http://stackoverflow.com/questions/945547/how-can-i-get-a-list-of-installed-fonts-on-windows-using-unmanaged-c[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900