1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFontEnumerator class for getting available fonts
4 // Author: Julian Smart, Vadim Zeitlin
5 // Modified by: extended to enumerate more than just font facenames and works
6 // not only on Windows now (VZ)
9 // Copyright: (c) Julian Smart, Vadim Zeitlin
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_FONTENUM_H_
14 #define _WX_FONTENUM_H_
20 #include "wx/fontenc.h"
21 #include "wx/arrstr.h"
23 // ----------------------------------------------------------------------------
24 // wxFontEnumerator enumerates all available fonts on the system or only the
25 // fonts with given attributes
26 // ----------------------------------------------------------------------------
28 class WXDLLIMPEXP_CORE wxFontEnumerator
33 // virtual dtor for the base class
34 virtual ~wxFontEnumerator() {}
36 // start enumerating font facenames (either all of them or those which
37 // support the given encoding) - will result in OnFacename() being
38 // called for each available facename (until they are exhausted or
39 // OnFacename returns false)
40 virtual bool EnumerateFacenames
42 wxFontEncoding encoding
= wxFONTENCODING_SYSTEM
, // all
43 bool fixedWidthOnly
= false
46 // enumerate the different encodings either for given font facename or for
47 // all facenames - will result in OnFontEncoding() being called for each
48 // available (facename, encoding) couple
49 virtual bool EnumerateEncodings(const wxString
& facename
= wxEmptyString
);
51 // callbacks which are called after one of EnumerateXXX() functions from
52 // above is invoked - all of them may return false to stop enumeration or
53 // true to continue with it
55 // called by EnumerateFacenames
56 virtual bool OnFacename(const wxString
& WXUNUSED(facename
))
59 // called by EnumerateEncodings
60 virtual bool OnFontEncoding(const wxString
& WXUNUSED(facename
),
61 const wxString
& WXUNUSED(encoding
))
66 // convenience function that returns array of facenames.
68 GetFacenames(wxFontEncoding encoding
= wxFONTENCODING_SYSTEM
, // all
69 bool fixedWidthOnly
= false);
71 // convenience function that returns array of all available encodings.
72 static wxArrayString
GetEncodings(const wxString
& facename
= wxEmptyString
);
74 // convenience function that returns true if the given face name exist
75 // in the user's system
76 static bool IsValidFacename(const wxString
&str
);
79 #ifdef wxHAS_UTF8_FONTS
80 // helper for ports that only use UTF-8 encoding natively
81 bool EnumerateEncodingsUTF8(const wxString
& facename
);
84 wxDECLARE_NO_COPY_CLASS(wxFontEnumerator
);
87 #endif // wxUSE_FONTENUM
89 #endif // _WX_FONTENUM_H_