]>
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 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
30 #include "wx/fontutil.h"
31 #include "wx/fontmap.h"
32 #include "wx/tokenzr.h"
34 #include "wx/module.h"
35 #include "wx/encinfo.h"
39 #include "wx/gtk/private.h"
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 void wxNativeFontInfo::Init()
50 int wxNativeFontInfo::GetPointSize() const
52 return pango_font_description_get_size( description
) / PANGO_SCALE
;
55 wxFontStyle
wxNativeFontInfo::GetStyle() const
57 wxFontStyle m_style
= wxFONTSTYLE_NORMAL
;
59 switch (pango_font_description_get_style( description
))
61 case PANGO_STYLE_NORMAL
:
62 m_style
= wxFONTSTYLE_NORMAL
;
64 case PANGO_STYLE_ITALIC
:
65 m_style
= wxFONTSTYLE_ITALIC
;
67 case PANGO_STYLE_OBLIQUE
:
68 m_style
= wxFONTSTYLE_SLANT
;
75 wxFontWeight
wxNativeFontInfo::GetWeight() const
77 wxFontWeight m_weight
= wxFONTWEIGHT_NORMAL
;
79 switch (pango_font_description_get_weight( description
))
81 case PANGO_WEIGHT_ULTRALIGHT
:
82 m_weight
= wxFONTWEIGHT_LIGHT
;
84 case PANGO_WEIGHT_LIGHT
:
85 m_weight
= wxFONTWEIGHT_LIGHT
;
87 case PANGO_WEIGHT_NORMAL
:
88 m_weight
= wxFONTWEIGHT_NORMAL
;
90 case PANGO_WEIGHT_BOLD
:
91 m_weight
= wxFONTWEIGHT_BOLD
;
93 case PANGO_WEIGHT_ULTRABOLD
:
94 m_weight
= wxFONTWEIGHT_BOLD
;
96 case PANGO_WEIGHT_HEAVY
:
97 m_weight
= wxFONTWEIGHT_BOLD
;
104 bool wxNativeFontInfo::GetUnderlined() const
109 wxString
wxNativeFontInfo::GetFaceName() const
111 wxString tmp
= wxGTK_CONV_BACK( pango_font_description_get_family( description
) );
116 wxFontFamily
wxNativeFontInfo::GetFamily() const
118 return wxFONTFAMILY_SWISS
;
121 wxFontEncoding
wxNativeFontInfo::GetEncoding() const
123 return wxFONTENCODING_SYSTEM
;
126 // ----------------------------------------------------------------------------
127 // wxNativeEncodingInfo
128 // ----------------------------------------------------------------------------
130 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
135 wxString
wxNativeEncodingInfo::ToString() const
137 return wxEmptyString
;
140 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)
145 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
146 wxNativeEncodingInfo
*info
)
156 #pragma message disable nosimpint
159 #include <X11/Xlib.h>
162 #pragma message enable nosimpint
165 #include "wx/utils.h" // for wxGetDisplay()
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
= (wxHashTable
*) 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()
253 g_fontHash
= (wxHashTable
*)NULL
;