title: How can I get a list of installed fonts on Windows including font style using c++
body: <p>I have been trying to get a list of installed fonts on Windows including font style.</p>
  
  <p>After investigation, I found out that I need to use: EnumFontFamiliesEx.
  I use it BUT I get only the font name and not all the styles of this font.</p>
  
  <p>for example: for font: "Verdana" </p>
  
  <p><a href="https://i.stack.imgur.com/ZlN05.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZlN05.png" alt="enter image description here"></a></p>
  
  <p>There are four different styles, But I get only one - the regular.
  My question is: how can I get the fonts list including all the styles? </p>
  
  <p>My code:</p>
  
  <pre><code>void getFonts()
  {
      LOGFONT lf;
      memset(&amp;lf, 0, sizeof(lf));
      lf.lfCharSet = DEFAULT_CHARSET;
      HDC hDC = GetDC(NULL);
      EnumFontFamiliesEx(hDC, &amp;lf, (FONTENUMPROC)(EnumFontFamExProc), NULL, 0);
  }
  
  int CALLBACK EnumFontFamExProc(
      ENUMLOGFONTEX *lpelfe,
      NEWTEXTMETRICEX *lpntme,
      DWORD FontType,
      LPARAM lParam
  )
  {
      UTF8String fontName = (lpelfe-&gt;elfFullName);
      return 1;
  }
  </code></pre>
  
  <p>ENUMLOGFONTEX *lpelfe - contains the font. but I don't get all the different styles</p>
  
  <p>after more investigation, I found out that if I change the lfFaceName to a specific font the method returns all styles.</p>
  
  <pre><code>// To enumerate all styles of all fonts for the ANSI character set 
  lf.lfFaceName[0] = '\0';
  lf.lfCharSet = ANSI_CHARSET;
  
  // To enumerate all styles of Arial font that cover the ANSI charset 
  hr = StringCchCopy( (LPSTR)lf.lfFaceName, LF_FACESIZE, "Arial" );
  </code></pre>
  
  <p>So I'm not sure what I should do, I need to get all the styles for all the installed fonts.</p>
  
  <p>Thank you in advance</p>