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_
16 #include "wx/fontenc.h"
17 #include "wx/arrstr.h"
19 #if wxUSE_PANGO || defined(__WXDFB__)
20 // defined if the port uses only UTF-8 font encodings internally
21 #define wxHAS_UTF8_FONTS
24 // ----------------------------------------------------------------------------
25 // wxFontEnumerator enumerates all available fonts on the system or only the
26 // fonts with given attributes
27 // ----------------------------------------------------------------------------
29 class WXDLLEXPORT wxFontEnumerator
34 // virtual dtor for the base class
35 virtual ~wxFontEnumerator() {}
37 // start enumerating font facenames (either all of them or those which
38 // support the given encoding) - will result in OnFacename() being
39 // called for each available facename (until they are exhausted or
40 // OnFacename returns false)
41 virtual bool EnumerateFacenames
43 wxFontEncoding encoding
= wxFONTENCODING_SYSTEM
, // all
44 bool fixedWidthOnly
= false
47 // enumerate the different encodings either for given font facename or for
48 // all facenames - will result in OnFontEncoding() being called for each
49 // available (facename, encoding) couple
50 virtual bool EnumerateEncodings(const wxString
& facename
= wxEmptyString
);
52 // callbacks which are called after one of EnumerateXXX() functions from
53 // above is invoked - all of them may return false to stop enumeration or
54 // true to continue with it
56 // called by EnumerateFacenames
57 virtual bool OnFacename(const wxString
& WXUNUSED(facename
))
60 // called by EnumerateEncodings
61 virtual bool OnFontEncoding(const wxString
& WXUNUSED(facename
),
62 const wxString
& WXUNUSED(encoding
))
67 // convenience function that returns array of facenames.
69 GetFacenames(wxFontEncoding encoding
= wxFONTENCODING_SYSTEM
, // all
70 bool fixedWidthOnly
= false);
72 // convenience function that returns array of all available encodings.
73 static wxArrayString
GetEncodings(const wxString
& facename
= wxEmptyString
);
75 // convenience function that returns true if the given face name exist
76 // in the user's system
77 static bool IsValidFacename(const wxString
&str
);
80 #ifdef wxHAS_UTF8_FONTS
81 // helper for ports that only use UTF-8 encoding natively
82 bool EnumerateEncodingsUTF8(const wxString
& facename
);
85 DECLARE_NO_COPY_CLASS(wxFontEnumerator
)
88 #endif // _WX_FONTENUM_H_