]>
git.saurik.com Git - wxWidgets.git/blob - src/cocoa/fontutil.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/fontutil.cpp
3 // Purpose: Font helper functions for X11 (GDK/X)
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/fontutil.h"
32 #include "wx/module.h"
35 #include "wx/fontmap.h"
36 #include "wx/tokenzr.h"
37 #include "wx/encinfo.h"
41 #include "wx/gtk/private.h"
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 void wxNativeFontInfo::Init()
52 int wxNativeFontInfo::GetPointSize() const
54 return pango_font_description_get_size( description
) / PANGO_SCALE
;
57 wxFontStyle
wxNativeFontInfo::GetStyle() const
59 wxFontStyle m_style
= wxFONTSTYLE_NORMAL
;
61 switch (pango_font_description_get_style( description
))
63 case PANGO_STYLE_NORMAL
:
64 m_style
= wxFONTSTYLE_NORMAL
;
66 case PANGO_STYLE_ITALIC
:
67 m_style
= wxFONTSTYLE_ITALIC
;
69 case PANGO_STYLE_OBLIQUE
:
70 m_style
= wxFONTSTYLE_SLANT
;
77 wxFontWeight
wxNativeFontInfo::GetWeight() const
79 wxFontWeight m_weight
= wxFONTWEIGHT_NORMAL
;
81 switch (pango_font_description_get_weight( description
))
83 case PANGO_WEIGHT_ULTRALIGHT
:
84 m_weight
= wxFONTWEIGHT_LIGHT
;
86 case PANGO_WEIGHT_LIGHT
:
87 m_weight
= wxFONTWEIGHT_LIGHT
;
89 case PANGO_WEIGHT_NORMAL
:
90 m_weight
= wxFONTWEIGHT_NORMAL
;
92 case PANGO_WEIGHT_BOLD
:
93 m_weight
= wxFONTWEIGHT_BOLD
;
95 case PANGO_WEIGHT_ULTRABOLD
:
96 m_weight
= wxFONTWEIGHT_BOLD
;
98 case PANGO_WEIGHT_HEAVY
:
99 m_weight
= wxFONTWEIGHT_BOLD
;
106 bool wxNativeFontInfo::GetUnderlined() const
111 wxString
wxNativeFontInfo::GetFaceName() const
113 wxString tmp
= wxGTK_CONV_BACK( pango_font_description_get_family( description
) );
118 wxFontFamily
wxNativeFontInfo::GetFamily() const
120 return wxFONTFAMILY_SWISS
;
123 wxFontEncoding
wxNativeFontInfo::GetEncoding() const
125 return wxFONTENCODING_SYSTEM
;
128 // ----------------------------------------------------------------------------
129 // wxNativeEncodingInfo
130 // ----------------------------------------------------------------------------
132 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
137 wxString
wxNativeEncodingInfo::ToString() const
139 return wxEmptyString
;
142 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)
147 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
148 wxNativeEncodingInfo
*info
)
158 #pragma message disable nosimpint
161 #include <X11/Xlib.h>
164 #pragma message enable nosimpint
167 #elif defined(__WXGTK__)
168 // we have to declare struct tm to avoid problems with first forward
169 // declaring it in C code (glib.h included from gdk.h does it) and then
170 // defining it when time.h is included from the headers below - this is
171 // known not to work at least with Sun CC 6.01
178 // ----------------------------------------------------------------------------
180 // ----------------------------------------------------------------------------
182 static wxHashTable
*g_fontHash
= NULL
;
184 // ----------------------------------------------------------------------------
186 // ----------------------------------------------------------------------------
188 // ============================================================================
190 // ============================================================================
192 // ----------------------------------------------------------------------------
193 // wxNativeEncodingInfo
194 // ----------------------------------------------------------------------------
196 // convert to/from the string representation: format is
197 // encodingid;registry;encoding[;facename]
198 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
203 wxString
wxNativeEncodingInfo::ToString() const
205 return wxEmptyString
;
208 // ----------------------------------------------------------------------------
210 // ----------------------------------------------------------------------------
212 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
213 wxNativeEncodingInfo
*info
)
218 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)
223 // ----------------------------------------------------------------------------
225 // ----------------------------------------------------------------------------
227 // ----------------------------------------------------------------------------
229 // ----------------------------------------------------------------------------
231 class wxFontModule
: public wxModule
238 DECLARE_DYNAMIC_CLASS(wxFontModule
)
241 IMPLEMENT_DYNAMIC_CLASS(wxFontModule
, wxModule
)
243 bool wxFontModule::OnInit()
245 g_fontHash
= new wxHashTable( wxKEY_STRING
);
250 void wxFontModule::OnExit()
252 wxDELETE(g_fontHash
);