+ HDC hDC = ::GetDC(NULL);
+
+#ifdef __WIN32__
+ LOGFONT lf;
+ lf.lfCharSet = m_charset;
+ wxStrncpy(lf.lfFaceName, m_facename, WXSIZEOF(lf.lfFaceName));
+ lf.lfPitchAndFamily = 0;
+ ::EnumFontFamiliesEx(hDC, &lf, (wxFONTENUMPROC)wxFontEnumeratorProc,
+ (LPARAM)this, 0 /* reserved */) ;
+#else // Win16
+ ::EnumFonts(hDC, (LPTSTR)NULL, (FONTENUMPROC)wxFontEnumeratorProc,
+ #ifdef STRICT
+ (LPARAM)
+ #else
+ (LPSTR)
+ #endif
+ this);
+#endif // Win32/16
+
+ ::ReleaseDC(NULL, hDC);
+}
+
+bool wxFontEnumeratorHelper::OnFont(const LPLOGFONT lf,
+ const LPTEXTMETRIC tm) const
+{
+ if ( m_enumEncodings )
+ {
+ // is this a new charset?
+ int cs = lf->lfCharSet;
+ if ( m_charsets.Index(cs) == wxNOT_FOUND )
+ {
+ wxConstCast(this, wxFontEnumeratorHelper)->m_charsets.Add(cs);
+
+ wxFontEncoding enc = wxGetFontEncFromCharSet(cs);
+ return m_fontEnum->OnFontEncoding(lf->lfFaceName,
+ wxFontMapper::GetEncodingName(enc));
+ }
+ else
+ {
+ // continue enumeration
+ return TRUE;
+ }
+ }
+
+ if ( m_fixedOnly )
+ {
+ // check that it's a fixed pitch font (there is *no* error here, the
+ // flag name is misleading!)
+ if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
+ {
+ // not a fixed pitch font
+ return TRUE;
+ }
+ }
+
+ if ( m_charset != -1 )
+ {
+ // check that we have the right encoding
+ if ( lf->lfCharSet != m_charset )
+ {
+ return TRUE;
+ }
+ }
+
+ return m_fontEnum->OnFacename(lf->lfFaceName);
+}
+
+// ----------------------------------------------------------------------------
+// wxFontEnumerator
+// ----------------------------------------------------------------------------
+
+bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
+ bool fixedWidthOnly)
+{
+ wxFontEnumeratorHelper fe(this);
+ if ( fe.SetEncoding(encoding) )
+ {
+ fe.SetFixedOnly(fixedWidthOnly);
+
+ fe.DoEnumerate();
+ }
+ // else: no such fonts, unknown encoding
+