Click here to Skip to main content
Sign Up to vote bad
good
See more: C++Windowsfont
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 20 Feb '13 - 7:24


2 solutions

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.
  Permalink  
Comments
Sergey Alexandrovich Kryukov - 20 Feb '13 - 19:55
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:57
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
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 508
1 Arun Vasu 275
2 Maciej Los 238
3 OriginalGriff 215
4 Mahesh Bailwal 200
0 Sergey Alexandrovich Kryukov 9,660
1 OriginalGriff 7,329
2 CPallini 3,968
3 Rohan Leuva 3,339
4 Maciej Los 2,851


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid