Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Windows font
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:24am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 at 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 at 20-Feb-13 19:57pm
   
So, I basically answered, please see.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
0 OriginalGriff 349
1 Nirav Prabtani 268
2 Richard Deeming 210
3 CHill60 170
4 _Amy 145
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,067
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100