/// <summary> /// 获取系统安装的等宽字体 /// </summary> /// <returns></returns> private static string[] GetEqualWidthFonts() { List <string> list = new List <string>(); Gdi32.FontEnumProc FontEnumProc = (ref Gdi32.ENUMLOGFONT lpelf, IntPtr lpntm, uint FontType, IntPtr lParam) => { if ((lpelf.elfLogFont.lfPitchAndFamily & 0x3) == 1) { string fontName = lpelf.elfLogFont.lfFaceName; if (list.FindIndex(m => m == fontName) < 0) { list.Add(fontName); } } return(1); }; IntPtr hdc = Gdi32.GetDC(IntPtr.Zero); Gdi32.EnumFontFamiliesEx(hdc, IntPtr.Zero, FontEnumProc, IntPtr.Zero, 0); Gdi32.ReleaseDC(IntPtr.Zero, hdc); return(list.ToArray()); }