]>
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"
42 #include "wx/gtk/private.h"
44 // ----------------------------------------------------------------------------
46 // ----------------------------------------------------------------------------
48 void wxNativeFontInfo::Init()
53 int wxNativeFontInfo::GetPointSize() const
55 return pango_font_description_get_size( description
) / PANGO_SCALE
;
58 wxFontStyle
wxNativeFontInfo::GetStyle() const
60 wxFontStyle m_style
= wxFONTSTYLE_NORMAL
;
62 switch (pango_font_description_get_style( description
))
64 case PANGO_STYLE_NORMAL
:
65 m_style
= wxFONTSTYLE_NORMAL
;
67 case PANGO_STYLE_ITALIC
:
68 m_style
= wxFONTSTYLE_ITALIC
;
70 case PANGO_STYLE_OBLIQUE
:
71 m_style
= wxFONTSTYLE_SLANT
;
78 wxFontWeight
wxNativeFontInfo::GetWeight() const
80 wxFontWeight m_weight
= wxFONTWEIGHT_NORMAL
;
82 switch (pango_font_description_get_weight( description
))
84 case PANGO_WEIGHT_ULTRALIGHT
:
85 m_weight
= wxFONTWEIGHT_LIGHT
;
87 case PANGO_WEIGHT_LIGHT
:
88 m_weight
= wxFONTWEIGHT_LIGHT
;
90 case PANGO_WEIGHT_NORMAL
:
91 m_weight
= wxFONTWEIGHT_NORMAL
;
93 case PANGO_WEIGHT_BOLD
:
94 m_weight
= wxFONTWEIGHT_BOLD
;
96 case PANGO_WEIGHT_ULTRABOLD
:
97 m_weight
= wxFONTWEIGHT_BOLD
;
99 case PANGO_WEIGHT_HEAVY
:
100 m_weight
= wxFONTWEIGHT_BOLD
;
107 bool wxNativeFontInfo::GetUnderlined() const
112 wxString
wxNativeFontInfo::GetFaceName() const
114 wxString tmp
= wxGTK_CONV_BACK( pango_font_description_get_family( description
) );
119 wxFontFamily
wxNativeFontInfo::GetFamily() const
121 return wxFONTFAMILY_SWISS
;
124 wxFontEncoding
wxNativeFontInfo::GetEncoding() const
126 return wxFONTENCODING_SYSTEM
;
129 // ----------------------------------------------------------------------------
130 // wxNativeEncodingInfo
131 // ----------------------------------------------------------------------------
133 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
138 wxString
wxNativeEncodingInfo::ToString() const
140 return wxEmptyString
;
143 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)
148 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
149 wxNativeEncodingInfo
*info
)
159 #pragma message disable nosimpint
162 #include <X11/Xlib.h>
165 #pragma message enable nosimpint
168 #include "wx/utils.h" // for wxGetDisplay()
169 #elif defined(__WXGTK__)
170 // we have to declare struct tm to avoid problems with first forward
171 // declaring it in C code (glib.h included from gdk.h does it) and then
172 // defining it when time.h is included from the headers below - this is
173 // known not to work at least with Sun CC 6.01
180 // ----------------------------------------------------------------------------
182 // ----------------------------------------------------------------------------
184 static wxHashTable
*g_fontHash
= (wxHashTable
*) NULL
;
186 // ----------------------------------------------------------------------------
188 // ----------------------------------------------------------------------------
190 // ============================================================================
192 // ============================================================================
194 // ----------------------------------------------------------------------------
195 // wxNativeEncodingInfo
196 // ----------------------------------------------------------------------------
198 // convert to/from the string representation: format is
199 // encodingid;registry;encoding[;facename]
200 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
205 wxString
wxNativeEncodingInfo::ToString() const
207 return wxEmptyString
;
210 // ----------------------------------------------------------------------------
212 // ----------------------------------------------------------------------------
214 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
215 wxNativeEncodingInfo
*info
)
220 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)
225 // ----------------------------------------------------------------------------
227 // ----------------------------------------------------------------------------
229 // ----------------------------------------------------------------------------
231 // ----------------------------------------------------------------------------
233 class wxFontModule
: public wxModule
240 DECLARE_DYNAMIC_CLASS(wxFontModule
)
243 IMPLEMENT_DYNAMIC_CLASS(wxFontModule
, wxModule
)
245 bool wxFontModule::OnInit()
247 g_fontHash
= new wxHashTable( wxKEY_STRING
);
252 void wxFontModule::OnExit()
256 g_fontHash
= (wxHashTable
*)NULL
;