]>
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
7 // Copyright: (c) Vadim Zeitlin
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #include "wx/fontutil.h"
31 #include "wx/module.h"
34 #include "wx/fontmap.h"
35 #include "wx/tokenzr.h"
36 #include "wx/encinfo.h"
40 #include "wx/gtk/private.h"
42 // ----------------------------------------------------------------------------
44 // ----------------------------------------------------------------------------
46 void wxNativeFontInfo::Init()
51 int wxNativeFontInfo::GetPointSize() const
53 return pango_font_description_get_size( description
) / PANGO_SCALE
;
56 wxFontStyle
wxNativeFontInfo::GetStyle() const
58 wxFontStyle m_style
= wxFONTSTYLE_NORMAL
;
60 switch (pango_font_description_get_style( description
))
62 case PANGO_STYLE_NORMAL
:
63 m_style
= wxFONTSTYLE_NORMAL
;
65 case PANGO_STYLE_ITALIC
:
66 m_style
= wxFONTSTYLE_ITALIC
;
68 case PANGO_STYLE_OBLIQUE
:
69 m_style
= wxFONTSTYLE_SLANT
;
76 wxFontWeight
wxNativeFontInfo::GetWeight() const
78 wxFontWeight m_weight
= wxFONTWEIGHT_NORMAL
;
80 switch (pango_font_description_get_weight( description
))
82 case PANGO_WEIGHT_ULTRALIGHT
:
83 m_weight
= wxFONTWEIGHT_LIGHT
;
85 case PANGO_WEIGHT_LIGHT
:
86 m_weight
= wxFONTWEIGHT_LIGHT
;
88 case PANGO_WEIGHT_NORMAL
:
89 m_weight
= wxFONTWEIGHT_NORMAL
;
91 case PANGO_WEIGHT_BOLD
:
92 m_weight
= wxFONTWEIGHT_BOLD
;
94 case PANGO_WEIGHT_ULTRABOLD
:
95 m_weight
= wxFONTWEIGHT_BOLD
;
97 case PANGO_WEIGHT_HEAVY
:
98 m_weight
= wxFONTWEIGHT_BOLD
;
105 bool wxNativeFontInfo::GetUnderlined() const
110 wxString
wxNativeFontInfo::GetFaceName() const
112 wxString tmp
= wxGTK_CONV_BACK( pango_font_description_get_family( description
) );
117 wxFontFamily
wxNativeFontInfo::GetFamily() const
119 return wxFONTFAMILY_SWISS
;
122 wxFontEncoding
wxNativeFontInfo::GetEncoding() const
124 return wxFONTENCODING_SYSTEM
;
127 // ----------------------------------------------------------------------------
128 // wxNativeEncodingInfo
129 // ----------------------------------------------------------------------------
131 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
136 wxString
wxNativeEncodingInfo::ToString() const
138 return wxEmptyString
;
141 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)
146 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
147 wxNativeEncodingInfo
*info
)
157 #pragma message disable nosimpint
160 #include <X11/Xlib.h>
163 #pragma message enable nosimpint
166 #elif defined(__WXGTK__)
167 // we have to declare struct tm to avoid problems with first forward
168 // declaring it in C code (glib.h included from gdk.h does it) and then
169 // defining it when time.h is included from the headers below - this is
170 // known not to work at least with Sun CC 6.01
177 // ----------------------------------------------------------------------------
179 // ----------------------------------------------------------------------------
181 static wxHashTable
*g_fontHash
= NULL
;
183 // ----------------------------------------------------------------------------
185 // ----------------------------------------------------------------------------
187 // ============================================================================
189 // ============================================================================
191 // ----------------------------------------------------------------------------
192 // wxNativeEncodingInfo
193 // ----------------------------------------------------------------------------
195 // convert to/from the string representation: format is
196 // encodingid;registry;encoding[;facename]
197 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
202 wxString
wxNativeEncodingInfo::ToString() const
204 return wxEmptyString
;
207 // ----------------------------------------------------------------------------
209 // ----------------------------------------------------------------------------
211 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
212 wxNativeEncodingInfo
*info
)
217 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)
222 // ----------------------------------------------------------------------------
224 // ----------------------------------------------------------------------------
226 // ----------------------------------------------------------------------------
228 // ----------------------------------------------------------------------------
230 class wxFontModule
: public wxModule
237 DECLARE_DYNAMIC_CLASS(wxFontModule
)
240 IMPLEMENT_DYNAMIC_CLASS(wxFontModule
, wxModule
)
242 bool wxFontModule::OnInit()
244 g_fontHash
= new wxHashTable( wxKEY_STRING
);
249 void wxFontModule::OnExit()
251 wxDELETE(g_fontHash
);