]>
git.saurik.com Git - wxWidgets.git/blob - src/cocoa/fontutil.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: unix/fontutil.cpp
3 // Purpose: Font helper functions for X11 (GDK/X)
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "fontutil.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
34 #include "wx/fontutil.h"
35 #include "wx/fontmap.h"
36 #include "wx/tokenzr.h"
38 #include "wx/module.h"
39 #include "wx/encinfo.h"
43 #include "wx/gtk/private.h"
45 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
49 void wxNativeFontInfo::Init()
54 int wxNativeFontInfo::GetPointSize() const
56 return pango_font_description_get_size( description
) / PANGO_SCALE
;
59 wxFontStyle
wxNativeFontInfo::GetStyle() const
61 wxFontStyle m_style
= wxFONTSTYLE_NORMAL
;
63 switch (pango_font_description_get_style( description
))
65 case PANGO_STYLE_NORMAL
:
66 m_style
= wxFONTSTYLE_NORMAL
;
68 case PANGO_STYLE_ITALIC
:
69 m_style
= wxFONTSTYLE_ITALIC
;
71 case PANGO_STYLE_OBLIQUE
:
72 m_style
= wxFONTSTYLE_SLANT
;
79 wxFontWeight
wxNativeFontInfo::GetWeight() const
81 wxFontWeight m_weight
= wxFONTWEIGHT_NORMAL
;
83 switch (pango_font_description_get_weight( description
))
85 case PANGO_WEIGHT_ULTRALIGHT
:
86 m_weight
= wxFONTWEIGHT_LIGHT
;
88 case PANGO_WEIGHT_LIGHT
:
89 m_weight
= wxFONTWEIGHT_LIGHT
;
91 case PANGO_WEIGHT_NORMAL
:
92 m_weight
= wxFONTWEIGHT_NORMAL
;
94 case PANGO_WEIGHT_BOLD
:
95 m_weight
= wxFONTWEIGHT_BOLD
;
97 case PANGO_WEIGHT_ULTRABOLD
:
98 m_weight
= wxFONTWEIGHT_BOLD
;
100 case PANGO_WEIGHT_HEAVY
:
101 m_weight
= wxFONTWEIGHT_BOLD
;
108 bool wxNativeFontInfo::GetUnderlined() const
113 wxString
wxNativeFontInfo::GetFaceName() const
115 wxString tmp
= wxGTK_CONV_BACK( pango_font_description_get_family( description
) );
120 wxFontFamily
wxNativeFontInfo::GetFamily() const
122 return wxFONTFAMILY_SWISS
;
125 wxFontEncoding
wxNativeFontInfo::GetEncoding() const
127 return wxFONTENCODING_SYSTEM
;
130 // ----------------------------------------------------------------------------
131 // wxNativeEncodingInfo
132 // ----------------------------------------------------------------------------
134 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
139 wxString
wxNativeEncodingInfo::ToString() const
141 return wxEmptyString
;
144 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)
149 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
150 wxNativeEncodingInfo
*info
)
160 #pragma message disable nosimpint
163 #include <X11/Xlib.h>
166 #pragma message enable nosimpint
169 #include "wx/utils.h" // for wxGetDisplay()
170 #elif defined(__WXGTK__)
171 // we have to declare struct tm to avoid problems with first forward
172 // declaring it in C code (glib.h included from gdk.h does it) and then
173 // defining it when time.h is included from the headers below - this is
174 // known not to work at least with Sun CC 6.01
181 // ----------------------------------------------------------------------------
183 // ----------------------------------------------------------------------------
185 static wxHashTable
*g_fontHash
= (wxHashTable
*) NULL
;
187 // ----------------------------------------------------------------------------
189 // ----------------------------------------------------------------------------
191 // ============================================================================
193 // ============================================================================
195 // ----------------------------------------------------------------------------
196 // wxNativeEncodingInfo
197 // ----------------------------------------------------------------------------
199 // convert to/from the string representation: format is
200 // encodingid;registry;encoding[;facename]
201 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
206 wxString
wxNativeEncodingInfo::ToString() const
208 return wxEmptyString
;
211 // ----------------------------------------------------------------------------
213 // ----------------------------------------------------------------------------
215 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
216 wxNativeEncodingInfo
*info
)
221 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)
226 // ----------------------------------------------------------------------------
228 // ----------------------------------------------------------------------------
230 // ----------------------------------------------------------------------------
232 // ----------------------------------------------------------------------------
234 class wxFontModule
: public wxModule
241 DECLARE_DYNAMIC_CLASS(wxFontModule
)
244 IMPLEMENT_DYNAMIC_CLASS(wxFontModule
, wxModule
)
246 bool wxFontModule::OnInit()
248 g_fontHash
= new wxHashTable( wxKEY_STRING
);
253 void wxFontModule::OnExit()
257 g_fontHash
= (wxHashTable
*)NULL
;