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)
8 // Copyright: (c) Julian Smart, Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FONTENUM_H_
13 #define _WX_FONTENUM_H_
19 #include "wx/fontenc.h"
20 #include "wx/arrstr.h"
22 // ----------------------------------------------------------------------------
23 // wxFontEnumerator enumerates all available fonts on the system or only the
24 // fonts with given attributes
25 // ----------------------------------------------------------------------------
27 class WXDLLIMPEXP_CORE wxFontEnumerator
32 // virtual dtor for the base class
33 virtual ~wxFontEnumerator() {}
35 // start enumerating font facenames (either all of them or those which
36 // support the given encoding) - will result in OnFacename() being
37 // called for each available facename (until they are exhausted or
38 // OnFacename returns false)
39 virtual bool EnumerateFacenames
41 wxFontEncoding encoding
= wxFONTENCODING_SYSTEM
, // all
42 bool fixedWidthOnly
= false
45 // enumerate the different encodings either for given font facename or for
46 // all facenames - will result in OnFontEncoding() being called for each
47 // available (facename, encoding) couple
48 virtual bool EnumerateEncodings(const wxString
& facename
= wxEmptyString
);
50 // callbacks which are called after one of EnumerateXXX() functions from
51 // above is invoked - all of them may return false to stop enumeration or
52 // true to continue with it
54 // called by EnumerateFacenames
55 virtual bool OnFacename(const wxString
& WXUNUSED(facename
))
58 // called by EnumerateEncodings
59 virtual bool OnFontEncoding(const wxString
& WXUNUSED(facename
),
60 const wxString
& WXUNUSED(encoding
))
65 // convenience function that returns array of facenames.
67 GetFacenames(wxFontEncoding encoding
= wxFONTENCODING_SYSTEM
, // all
68 bool fixedWidthOnly
= false);
70 // convenience function that returns array of all available encodings.
71 static wxArrayString
GetEncodings(const wxString
& facename
= wxEmptyString
);
73 // convenience function that returns true if the given face name exist
74 // in the user's system
75 static bool IsValidFacename(const wxString
&str
);
78 #ifdef wxHAS_UTF8_FONTS
79 // helper for ports that only use UTF-8 encoding natively
80 bool EnumerateEncodingsUTF8(const wxString
& facename
);
83 wxDECLARE_NO_COPY_CLASS(wxFontEnumerator
);
86 #endif // wxUSE_FONTENUM
88 #endif // _WX_FONTENUM_H_