title: How to get all monospaced fonts in Windows?
body: <p>I've seen <a href="https://stackoverflow.com/questions/224865/how-do-i-get-all-installed-fixed-width-fonts">How do I get all installed fixed-width fonts?</a>, but I can't make it work:</p>
  
  <pre><code>internal class NativeMethods
  {
      public const Int32 LF_FACESIZE = 32;
      public const Int32 FIXED_PITCH = 1;
  
      [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
      public class LOGFONT
      {
          public Int32 lfHeight = 0;
          public Int32 lfWidth = 0;
          public Int32 lfEscapement = 0;
          public Int32 lfOrientation = 0;
          public Int32 lfWeight = 0;
          public Byte lfItalic = 0;
          public Byte lfUnderline = 0;
          public Byte lfStrikeOut = 0;
          public Byte lfCharSet = 0;
          public Byte lfOutPrecision = 0;
          public Byte lfClipPrecision = 0;
          public Byte lfQuality = 0;
          public Byte lfPitchAndFamily = 0;
  
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = LF_FACESIZE)]
          public String lfFaceName = string.Empty;
      }
  }
  
  
  public partial class MainForm : Form
  {
      private string font_names = null;
  
      public MainForm()
      {
          InitializeComponent();
  
          StringBuilder sb = new StringBuilder();
          foreach (var font_family in FontFamily.Families)
          {
              if (font_family.IsStyleAvailable(FontStyle.Regular))
              {
                  var lf = new NativeMethods.LOGFONT();
                  Font font = new Font(font_family, 9.0f);
                  font.ToLogFont(lf);
                  if ((lf.lfPitchAndFamily &amp; 0x3) == NativeMethods.FIXED_PITCH)
                  {
                      sb.AppendLine(font_family.Name);
                  }
              }
          }
          font_names = sb.ToString();
      }
  
      private void MainForm_Paint(object sender, PaintEventArgs e)
      {
          e.Graphics.DrawString(font_names, SystemFonts.MessageBoxFont, SystemBrushes.WindowText, 10.0f, 10.0f);
      }
  }
  </code></pre>
  
  <p>It seem no matter what font it is, the <code>lfPitchAndFamily</code> is always zero.</p>
  
  <p>So how get all monospaced fonts?</p>