1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: font-related helper functions
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // General note: this header is private to wxWindows and is not supposed to be
13 // included by user code. The functions declared here are implemented in
14 // msw/fontutil.cpp for Windows, unix/fontutil.cpp for GTK/Motif &c.
16 #ifndef _WX_FONTUTIL_H_
17 #define _WX_FONTUTIL_H_
20 #pragma interface "fontutil.h"
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 #include "wx/font.h" // for wxFont and wxFontEncoding
29 #if defined(__WXMSW__)
31 #include "wx/msw/winundef.h"
34 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
38 // wxNativeFontInfo is platform-specific font representation: this struct
39 // should be considered as opaque font description only used by the native
40 // functions, the user code can only get the objects of this type from
41 // somewhere and pass it somewhere else (possibly save them somewhere using
42 // ToString() and restore them using FromString())
44 // NB: it is a POD currently for max efficiency but if it continues to grow
45 // further it might make sense to make it a real class with virtual methods
46 struct WXDLLEXPORT wxNativeFontInfo
48 #if defined(__WXGTK__) || defined(__WXMOTIF__)
49 // the components of the XLFD
50 wxString fontElements
[14];
55 // init the elements from an XLFD, return TRUE if ok
56 bool FromXFontName(const wxString
& xFontName
);
58 // generate an XLFD using the fontElements
59 wxString
GetXFontName() const;
60 #elif defined(__WXMSW__)
62 #else // other platforms
64 // This is a generic implementation that should work on all ports
65 // without specific support by the port.
67 #define wxNO_NATIVE_FONTINFO
75 wxFontEncoding encoding
;
78 // default ctor (default copy ctor is ok)
79 wxNativeFontInfo() { Init(); }
81 // reset to the default state
84 // accessors and modifiers for the font elements
85 int GetPointSize() const;
86 wxFontStyle
GetStyle() const;
87 wxFontWeight
GetWeight() const;
88 bool GetUnderlined() const;
89 wxString
GetFaceName() const;
90 wxFontFamily
GetFamily() const;
91 wxFontEncoding
GetEncoding() const;
93 void SetPointSize(int pointsize
);
94 void SetStyle(wxFontStyle style
);
95 void SetWeight(wxFontWeight weight
);
96 void SetUnderlined(bool underlined
);
97 void SetFaceName(wxString facename
);
98 void SetFamily(wxFontFamily family
);
99 void SetEncoding(wxFontEncoding encoding
);
101 // it is important to be able to serialize wxNativeFontInfo objects to be
102 // able to store them (in config file, for example)
103 bool FromString(const wxString
& s
);
104 wxString
ToString() const;
106 // we also want to present the native font descriptions to the user in some
107 // human-readable form (it is not platform independent neither, but can
108 // hopefully be understood by the user)
109 bool FromUserString(const wxString
& s
);
110 wxString
ToUserString() const;
113 // ----------------------------------------------------------------------------
114 // font-related functions (common)
115 // ----------------------------------------------------------------------------
117 // translate a wxFontEncoding into native encoding parameter (defined above),
118 // returning TRUE if an (exact) macth could be found, FALSE otherwise (without
119 // attempting any substitutions)
120 extern bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
121 wxNativeEncodingInfo
*info
);
123 // test for the existence of the font described by this facename/encoding,
124 // return TRUE if such font(s) exist, FALSE otherwise
125 extern bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
);
127 // ----------------------------------------------------------------------------
128 // font-related functions (X and GTK)
129 // ----------------------------------------------------------------------------
131 #ifdef _WX_X_FONTLIKE
132 #include "wx/unix/fontutil.h"
135 // ----------------------------------------------------------------------------
136 // font-related functions (MGL)
137 // ----------------------------------------------------------------------------
140 #include "wx/mgl/fontutil.h"
143 #endif // _WX_FONTUTIL_H_