]>
Commit | Line | Data |
---|---|---|
e9576ca5 | 1 | ///////////////////////////////////////////////////////////////////////////// |
df91131c | 2 | // Name: src/mac/carbon/font.cpp |
e9576ca5 | 3 | // Purpose: wxFont class |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
e9576ca5 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
65571936 | 9 | // Licence: wxWindows licence |
e9576ca5 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
3e527073 SC |
12 | #include "wx/wxprec.h" |
13 | ||
e9576ca5 | 14 | #include "wx/font.h" |
df91131c WS |
15 | |
16 | #ifndef WX_PRECOMP | |
17 | #include "wx/string.h" | |
de6185e2 | 18 | #include "wx/utils.h" |
987e9419 | 19 | #include "wx/intl.h" |
dd05139a | 20 | #include "wx/gdicmn.h" |
162f6b2a | 21 | #include "wx/log.h" |
df91131c WS |
22 | #endif |
23 | ||
5b781a67 | 24 | #include "wx/fontutil.h" |
ccd67a6a | 25 | #include "wx/graphics.h" |
3b7e6277 | 26 | |
76a5e5d2 | 27 | #include "wx/mac/private.h" |
6eaa4426 | 28 | |
768c6e8b | 29 | #ifndef __DARWIN__ |
7f0c3a63 | 30 | #include <ATSUnicode.h> |
768c6e8b | 31 | #endif |
76a5e5d2 | 32 | |
6eaa4426 | 33 | |
e9576ca5 | 34 | IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) |
e9576ca5 | 35 | |
6eaa4426 | 36 | |
3bf5a59b VZ |
37 | class WXDLLEXPORT wxFontRefData: public wxGDIRefData |
38 | { | |
39 | friend class WXDLLEXPORT wxFont; | |
6eaa4426 | 40 | |
3bf5a59b VZ |
41 | public: |
42 | wxFontRefData() | |
43 | : m_fontId(0) | |
44 | , m_pointSize(10) | |
45 | , m_family(wxDEFAULT) | |
46 | , m_style(wxNORMAL) | |
47 | , m_weight(wxNORMAL) | |
df91131c | 48 | , m_underlined(false) |
c277569a | 49 | , m_faceName(wxT("applicationfont")) |
3bf5a59b | 50 | , m_encoding(wxFONTENCODING_DEFAULT) |
2a0155df | 51 | , m_macFontFamily(0) |
3bf5a59b VZ |
52 | , m_macFontSize(0) |
53 | , m_macFontStyle(0) | |
3e527073 | 54 | , m_macATSUStyle(0) |
e369bddb | 55 | , m_macATSUFontID(0) |
3bf5a59b | 56 | { |
c277569a SC |
57 | Init(m_pointSize, m_family, m_style, m_weight, |
58 | m_underlined, m_faceName, m_encoding); | |
3bf5a59b VZ |
59 | } |
60 | ||
61 | wxFontRefData(const wxFontRefData& data) | |
62 | : wxGDIRefData() | |
63 | , m_fontId(data.m_fontId) | |
64 | , m_pointSize(data.m_pointSize) | |
65 | , m_family(data.m_family) | |
66 | , m_style(data.m_style) | |
67 | , m_weight(data.m_weight) | |
68 | , m_underlined(data.m_underlined) | |
69 | , m_faceName(data.m_faceName) | |
70 | , m_encoding(data.m_encoding) | |
2a0155df | 71 | , m_macFontFamily(data.m_macFontFamily) |
3bf5a59b VZ |
72 | , m_macFontSize(data.m_macFontSize) |
73 | , m_macFontStyle(data.m_macFontStyle) | |
3e527073 | 74 | , m_macATSUStyle(0) |
e369bddb | 75 | , m_macATSUFontID(data.m_macATSUFontID) |
3bf5a59b VZ |
76 | { |
77 | Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight, | |
78 | data.m_underlined, data.m_faceName, data.m_encoding); | |
79 | } | |
80 | ||
81 | wxFontRefData(int size, | |
82 | int family, | |
83 | int style, | |
84 | int weight, | |
85 | bool underlined, | |
86 | const wxString& faceName, | |
87 | wxFontEncoding encoding) | |
88 | : m_fontId(0) | |
89 | , m_pointSize(size) | |
90 | , m_family(family) | |
91 | , m_style(style) | |
92 | , m_weight(weight) | |
93 | , m_underlined(underlined) | |
94 | , m_faceName(faceName) | |
95 | , m_encoding(encoding) | |
2a0155df | 96 | , m_macFontFamily(0) |
3bf5a59b VZ |
97 | , m_macFontSize(0) |
98 | , m_macFontStyle(0) | |
3e527073 | 99 | , m_macATSUStyle(0) |
e369bddb | 100 | , m_macATSUFontID(0) |
3bf5a59b VZ |
101 | { |
102 | Init(size, family, style, weight, underlined, faceName, encoding); | |
103 | } | |
104 | ||
105 | virtual ~wxFontRefData(); | |
6eaa4426 DS |
106 | |
107 | void SetNoAntiAliasing( bool no = true ) | |
108 | { m_noAA = no; } | |
109 | ||
110 | bool GetNoAntiAliasing() const | |
111 | { return m_noAA; } | |
112 | ||
2a0155df | 113 | void MacFindFont(); |
6eaa4426 | 114 | |
3bf5a59b VZ |
115 | protected: |
116 | // common part of all ctors | |
117 | void Init(int size, | |
118 | int family, | |
119 | int style, | |
120 | int weight, | |
121 | bool underlined, | |
122 | const wxString& faceName, | |
123 | wxFontEncoding encoding); | |
124 | ||
125 | // font characterstics | |
e369bddb GD |
126 | int m_fontId; |
127 | int m_pointSize; | |
128 | int m_family; | |
129 | int m_style; | |
130 | int m_weight; | |
131 | bool m_underlined; | |
132 | wxString m_faceName; | |
133 | wxFontEncoding m_encoding; | |
3bf5a59b | 134 | bool m_noAA; // No anti-aliasing |
6eaa4426 | 135 | |
3bf5a59b | 136 | public: |
2a0155df SC |
137 | FMFontFamily m_macFontFamily; |
138 | FMFontSize m_macFontSize; | |
139 | FMFontStyle m_macFontStyle; | |
6eaa4426 | 140 | |
facd6764 | 141 | // ATSU Font Information |
6eaa4426 | 142 | |
3103e8a9 | 143 | // this is split into an ATSU font id that may |
facd6764 SC |
144 | // contain some styles (special bold fonts etc) and |
145 | // these are the additional qd styles that are not | |
146 | // included in the ATSU font id | |
3e527073 | 147 | ATSUStyle m_macATSUStyle ; |
facd6764 | 148 | ATSUFontID m_macATSUFontID; |
2a0155df | 149 | FMFontStyle m_macATSUAdditionalQDStyles ; |
6eaa4426 | 150 | |
facd6764 SC |
151 | // for true themeing support we must store the correct font |
152 | // information here, as this speeds up and optimizes rendering | |
153 | ThemeFontID m_macThemeFontID ; | |
3bf5a59b | 154 | |
6eaa4426 | 155 | wxNativeFontInfo m_info; |
3bf5a59b | 156 | }; |
6eaa4426 | 157 | |
68c95704 | 158 | #define M_FONTDATA ((wxFontRefData*)m_refData) |
873fd4af | 159 | |
6eaa4426 | 160 | |
e7549107 SC |
161 | // ============================================================================ |
162 | // implementation | |
163 | // ============================================================================ | |
164 | ||
165 | // ---------------------------------------------------------------------------- | |
166 | // wxFontRefData | |
167 | // ---------------------------------------------------------------------------- | |
168 | ||
169 | void wxFontRefData::Init(int pointSize, | |
6eaa4426 DS |
170 | int family, |
171 | int style, | |
172 | int weight, | |
173 | bool underlined, | |
174 | const wxString& faceName, | |
175 | wxFontEncoding encoding) | |
e9576ca5 | 176 | { |
e7549107 SC |
177 | m_style = style; |
178 | m_pointSize = pointSize; | |
179 | m_family = family; | |
180 | m_style = style; | |
181 | m_weight = weight; | |
182 | m_underlined = underlined; | |
183 | m_faceName = faceName; | |
184 | m_encoding = encoding; | |
185 | ||
2a0155df | 186 | m_macFontFamily = 0 ; |
d84afea9 GD |
187 | m_macFontSize = 0; |
188 | m_macFontStyle = 0; | |
facd6764 SC |
189 | m_macATSUFontID = 0; |
190 | m_macATSUAdditionalQDStyles = 0 ; | |
3e527073 | 191 | m_macATSUStyle = NULL ; |
6eaa4426 | 192 | |
facd6764 | 193 | m_macThemeFontID = kThemeCurrentPortFont ; |
6eaa4426 | 194 | m_noAA = false; |
e9576ca5 SC |
195 | } |
196 | ||
197 | wxFontRefData::~wxFontRefData() | |
198 | { | |
3e527073 SC |
199 | if ( m_macATSUStyle ) |
200 | { | |
201 | ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle); | |
202 | m_macATSUStyle = NULL ; | |
203 | } | |
e9576ca5 SC |
204 | } |
205 | ||
519cb848 SC |
206 | void wxFontRefData::MacFindFont() |
207 | { | |
2a0155df | 208 | OSStatus status ; |
de6185e2 | 209 | |
2a0155df | 210 | Str255 qdFontName ; |
6eaa4426 | 211 | if ( m_macThemeFontID != kThemeCurrentPortFont ) |
e40298d5 | 212 | { |
2a0155df SC |
213 | Style style ; |
214 | GetThemeFont( m_macThemeFontID, GetApplicationScript(), qdFontName, &m_macFontSize, &style ); | |
215 | m_macFontStyle = style ; | |
216 | m_faceName = wxMacMakeStringFromPascal( qdFontName ); | |
facd6764 SC |
217 | if ( m_macFontStyle & bold ) |
218 | m_weight = wxBOLD ; | |
219 | else | |
220 | m_weight = wxNORMAL ; | |
221 | if ( m_macFontStyle & italic ) | |
222 | m_style = wxITALIC ; | |
223 | if ( m_macFontStyle & underline ) | |
224 | m_underlined = true ; | |
facd6764 | 225 | m_pointSize = m_macFontSize ; |
4913272f | 226 | #ifndef __LP64__ |
2a0155df | 227 | m_macFontFamily = FMGetFontFamilyFromName( qdFontName ); |
4913272f | 228 | #endif |
e40298d5 JS |
229 | } |
230 | else | |
231 | { | |
df91131c | 232 | if ( m_faceName.empty() ) |
facd6764 | 233 | { |
2a0155df | 234 | if ( m_family == wxDEFAULT ) |
facd6764 | 235 | { |
4913272f | 236 | #ifndef __LP64__ |
2a0155df SC |
237 | m_macFontFamily = GetAppFont(); |
238 | FMGetFontFamilyName(m_macFontFamily,qdFontName); | |
239 | m_faceName = wxMacMakeStringFromPascal( qdFontName ); | |
4913272f | 240 | #endif |
2a0155df SC |
241 | } |
242 | else | |
243 | { | |
244 | switch ( m_family ) | |
245 | { | |
246 | case wxSCRIPT : | |
247 | case wxROMAN : | |
248 | case wxDECORATIVE : | |
249 | m_faceName = wxT("Times"); | |
250 | break ; | |
251 | ||
252 | case wxSWISS : | |
253 | m_faceName = wxT("Lucida Grande"); | |
254 | break ; | |
255 | ||
256 | case wxMODERN : | |
257 | m_faceName = wxT("Monaco"); | |
258 | break ; | |
259 | ||
260 | default: | |
261 | m_faceName = wxT("Times"); | |
262 | break ; | |
263 | } | |
4913272f | 264 | #ifndef __LP64__ |
2a0155df SC |
265 | wxMacStringToPascal( m_faceName , qdFontName ); |
266 | m_macFontFamily = FMGetFontFamilyFromName( qdFontName ); | |
dedf5d9f SC |
267 | if ( m_macFontFamily == kInvalidFontFamily ) |
268 | { | |
269 | wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName ); | |
270 | m_macFontFamily = GetAppFont(); | |
271 | } | |
4913272f | 272 | #endif |
facd6764 | 273 | } |
facd6764 | 274 | } |
e40298d5 JS |
275 | else |
276 | { | |
4913272f | 277 | #ifndef __LP64__ |
facd6764 | 278 | if ( m_faceName == wxT("systemfont") ) |
2a0155df | 279 | m_macFontFamily = GetSysFont(); |
facd6764 | 280 | else if ( m_faceName == wxT("applicationfont") ) |
2a0155df | 281 | m_macFontFamily = GetAppFont(); |
facd6764 | 282 | else |
4913272f SC |
283 | #else |
284 | if ( m_faceName == wxT("systemfont") ) | |
285 | m_faceName = wxT("Lucida Grande"); | |
286 | else if ( m_faceName == wxT("applicationfont") ) | |
287 | m_faceName = wxT("Lucida Grande"); | |
288 | #endif | |
facd6764 | 289 | { |
2a0155df SC |
290 | wxMacCFStringHolder cf( m_faceName, wxLocale::GetSystemEncoding() ); |
291 | ATSFontFamilyRef atsfamily = ATSFontFamilyFindFromName( cf , kATSOptionFlagsDefault ); | |
dedf5d9f SC |
292 | if ( atsfamily == (ATSFontFamilyRef) -1 ) |
293 | { | |
294 | wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName ); | |
295 | m_macFontFamily = GetAppFont(); | |
296 | } | |
297 | else | |
298 | m_macFontFamily = FMGetFontFamilyFromATSFontFamilyRef( atsfamily ); | |
facd6764 | 299 | } |
e40298d5 | 300 | } |
facd6764 SC |
301 | |
302 | m_macFontStyle = 0; | |
303 | if (m_weight == wxBOLD) | |
304 | m_macFontStyle |= bold; | |
6eaa4426 | 305 | if (m_style == wxITALIC || m_style == wxSLANT) |
facd6764 | 306 | m_macFontStyle |= italic; |
6eaa4426 | 307 | if (m_underlined) |
facd6764 SC |
308 | m_macFontStyle |= underline; |
309 | m_macFontSize = m_pointSize ; | |
e40298d5 JS |
310 | } |
311 | ||
facd6764 | 312 | // we try to get as much styles as possible into ATSU |
3e527073 | 313 | |
6eaa4426 | 314 | |
2a0155df SC |
315 | // ATSUFontID and FMFont are equivalent |
316 | FMFontStyle intrinsicStyle = 0 ; | |
4913272f | 317 | #ifndef __LP64__ |
2a0155df SC |
318 | status = FMGetFontFromFontFamilyInstance( m_macFontFamily , m_macFontStyle , &m_macATSUFontID , &intrinsicStyle); |
319 | wxASSERT_MSG( status == noErr , wxT("couldn't get an ATSUFont from font family") ); | |
4913272f | 320 | #endif |
2a0155df | 321 | m_macATSUAdditionalQDStyles = m_macFontStyle & (~intrinsicStyle ); |
de6185e2 | 322 | |
3e527073 SC |
323 | if ( m_macATSUStyle ) |
324 | { | |
325 | ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle); | |
326 | m_macATSUStyle = NULL ; | |
327 | } | |
6eaa4426 | 328 | |
2a0155df SC |
329 | status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUStyle); |
330 | wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ); | |
6eaa4426 | 331 | |
3e527073 SC |
332 | ATSUAttributeTag atsuTags[] = |
333 | { | |
2a0155df SC |
334 | kATSUFontTag , |
335 | kATSUSizeTag , | |
336 | kATSUVerticalCharacterTag, | |
337 | kATSUQDBoldfaceTag , | |
338 | kATSUQDItalicTag , | |
339 | kATSUQDUnderlineTag , | |
340 | kATSUQDCondensedTag , | |
341 | kATSUQDExtendedTag , | |
6eaa4426 DS |
342 | }; |
343 | ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = | |
3e527073 | 344 | { |
2a0155df SC |
345 | sizeof( ATSUFontID ) , |
346 | sizeof( Fixed ) , | |
347 | sizeof( ATSUVerticalCharacterType), | |
348 | sizeof( Boolean ) , | |
349 | sizeof( Boolean ) , | |
350 | sizeof( Boolean ) , | |
351 | sizeof( Boolean ) , | |
352 | sizeof( Boolean ) , | |
6eaa4426 DS |
353 | }; |
354 | ||
3e527073 SC |
355 | Boolean kTrue = true ; |
356 | Boolean kFalse = false ; | |
357 | ||
2a0155df | 358 | Fixed atsuSize = IntToFixed( m_macFontSize ); |
3e527073 | 359 | ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal; |
6eaa4426 | 360 | ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = |
3e527073 SC |
361 | { |
362 | &m_macATSUFontID , | |
363 | &atsuSize , | |
364 | &kHorizontal, | |
365 | (m_macATSUAdditionalQDStyles & bold) ? &kTrue : &kFalse , | |
366 | (m_macATSUAdditionalQDStyles & italic) ? &kTrue : &kFalse , | |
367 | (m_macATSUAdditionalQDStyles & underline) ? &kTrue : &kFalse , | |
368 | (m_macATSUAdditionalQDStyles & condense) ? &kTrue : &kFalse , | |
369 | (m_macATSUAdditionalQDStyles & extend) ? &kTrue : &kFalse , | |
6eaa4426 DS |
370 | }; |
371 | ||
372 | status = ::ATSUSetAttributes( | |
373 | (ATSUStyle)m_macATSUStyle, | |
374 | sizeof(atsuTags) / sizeof(ATSUAttributeTag) , | |
3e527073 SC |
375 | atsuTags, atsuSizes, atsuValues); |
376 | ||
2a0155df | 377 | wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") ); |
519cb848 SC |
378 | } |
379 | ||
e7549107 SC |
380 | // ---------------------------------------------------------------------------- |
381 | // wxFont | |
382 | // ---------------------------------------------------------------------------- | |
e9576ca5 | 383 | |
5b781a67 SC |
384 | bool wxFont::Create(const wxNativeFontInfo& info) |
385 | { | |
6eaa4426 DS |
386 | return Create( |
387 | info.pointSize, info.family, info.style, info.weight, | |
388 | info.underlined, info.faceName, info.encoding ); | |
5b781a67 SC |
389 | } |
390 | ||
3b7e6277 GD |
391 | wxFont::wxFont(const wxString& fontdesc) |
392 | { | |
393 | wxNativeFontInfo info; | |
394 | if ( info.FromString(fontdesc) ) | |
395 | (void)Create(info); | |
396 | } | |
397 | ||
e7549107 | 398 | bool wxFont::Create(int pointSize, |
6eaa4426 DS |
399 | int family, |
400 | int style, | |
401 | int weight, | |
402 | bool underlined, | |
403 | const wxString& faceName, | |
404 | wxFontEncoding encoding) | |
e9576ca5 SC |
405 | { |
406 | UnRef(); | |
6eaa4426 DS |
407 | |
408 | m_refData = new wxFontRefData( | |
409 | pointSize, family, style, weight, | |
410 | underlined, faceName, encoding); | |
e9576ca5 SC |
411 | |
412 | RealizeResource(); | |
413 | ||
6eaa4426 | 414 | return true; |
e9576ca5 SC |
415 | } |
416 | ||
6eaa4426 | 417 | bool wxFont::MacCreateThemeFont(wxUint16 themeFontID) |
facd6764 SC |
418 | { |
419 | UnRef(); | |
6eaa4426 DS |
420 | |
421 | m_refData = new wxFontRefData( | |
422 | 12, wxDEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, | |
423 | false, wxEmptyString, wxFONTENCODING_DEFAULT ); | |
424 | ||
facd6764 SC |
425 | M_FONTDATA->m_macThemeFontID = themeFontID ; |
426 | RealizeResource(); | |
427 | ||
6eaa4426 | 428 | return true; |
facd6764 SC |
429 | } |
430 | ||
e9576ca5 SC |
431 | wxFont::~wxFont() |
432 | { | |
e9576ca5 SC |
433 | } |
434 | ||
435 | bool wxFont::RealizeResource() | |
436 | { | |
2a0155df | 437 | M_FONTDATA->MacFindFont(); |
6eaa4426 DS |
438 | |
439 | return true; | |
e9576ca5 SC |
440 | } |
441 | ||
51abe921 SC |
442 | void wxFont::SetEncoding(wxFontEncoding encoding) |
443 | { | |
444 | Unshare(); | |
445 | ||
446 | M_FONTDATA->m_encoding = encoding; | |
447 | ||
448 | RealizeResource(); | |
449 | } | |
450 | ||
e9576ca5 SC |
451 | void wxFont::Unshare() |
452 | { | |
e40298d5 JS |
453 | // Don't change shared data |
454 | if (!m_refData) | |
e9576ca5 | 455 | { |
e40298d5 JS |
456 | m_refData = new wxFontRefData(); |
457 | } | |
e9576ca5 SC |
458 | else |
459 | { | |
e40298d5 JS |
460 | wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); |
461 | UnRef(); | |
462 | m_refData = ref; | |
463 | } | |
e9576ca5 SC |
464 | } |
465 | ||
466 | void wxFont::SetPointSize(int pointSize) | |
467 | { | |
468 | Unshare(); | |
469 | ||
470 | M_FONTDATA->m_pointSize = pointSize; | |
471 | ||
472 | RealizeResource(); | |
473 | } | |
474 | ||
475 | void wxFont::SetFamily(int family) | |
476 | { | |
477 | Unshare(); | |
478 | ||
479 | M_FONTDATA->m_family = family; | |
480 | ||
481 | RealizeResource(); | |
482 | } | |
483 | ||
484 | void wxFont::SetStyle(int style) | |
485 | { | |
486 | Unshare(); | |
487 | ||
488 | M_FONTDATA->m_style = style; | |
489 | ||
490 | RealizeResource(); | |
491 | } | |
492 | ||
493 | void wxFont::SetWeight(int weight) | |
494 | { | |
495 | Unshare(); | |
496 | ||
497 | M_FONTDATA->m_weight = weight; | |
498 | ||
499 | RealizeResource(); | |
500 | } | |
501 | ||
85ab460e | 502 | bool wxFont::SetFaceName(const wxString& faceName) |
e9576ca5 SC |
503 | { |
504 | Unshare(); | |
505 | ||
506 | M_FONTDATA->m_faceName = faceName; | |
507 | ||
508 | RealizeResource(); | |
85ab460e VZ |
509 | |
510 | return wxFontBase::SetFaceName(faceName); | |
e9576ca5 SC |
511 | } |
512 | ||
513 | void wxFont::SetUnderlined(bool underlined) | |
514 | { | |
515 | Unshare(); | |
516 | ||
517 | M_FONTDATA->m_underlined = underlined; | |
518 | ||
519 | RealizeResource(); | |
520 | } | |
521 | ||
ac17f9b1 SC |
522 | void wxFont::SetNoAntiAliasing( bool no ) |
523 | { | |
524 | Unshare(); | |
525 | ||
526 | M_FONTDATA->SetNoAntiAliasing( no ); | |
527 | ||
528 | RealizeResource(); | |
529 | } | |
530 | ||
e7549107 SC |
531 | // ---------------------------------------------------------------------------- |
532 | // accessors | |
533 | // ---------------------------------------------------------------------------- | |
534 | ||
fcb35beb VZ |
535 | // TODO: insert checks everywhere for M_FONTDATA == NULL! |
536 | ||
e7549107 | 537 | int wxFont::GetPointSize() const |
e9576ca5 | 538 | { |
77eddfb7 | 539 | wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); |
6eaa4426 | 540 | |
e7549107 | 541 | return M_FONTDATA->m_pointSize; |
e9576ca5 SC |
542 | } |
543 | ||
ccd67a6a KO |
544 | wxSize wxFont::GetPixelSize() const |
545 | { | |
546 | #if wxUSE_GRAPHICS_CONTEXT | |
547 | // TODO: consider caching the value | |
548 | wxGraphicsContext* dc = wxGraphicsContext::CreateFromNative((CGContextRef) NULL); | |
40503c98 | 549 | dc->SetFont(*(wxFont *)this,*wxBLACK); |
ccd67a6a | 550 | wxDouble width, height = 0; |
8a438f46 VZ |
551 | dc->GetTextExtent( wxT("g"), &width, &height, NULL, NULL); |
552 | return wxSize((int)width, (int)height); | |
ccd67a6a KO |
553 | #else |
554 | wxFontBase::GetPixelSize(); | |
555 | #endif | |
556 | } | |
557 | ||
e7549107 | 558 | int wxFont::GetFamily() const |
e9576ca5 | 559 | { |
77eddfb7 | 560 | wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); |
6eaa4426 | 561 | |
e7549107 | 562 | return M_FONTDATA->m_family; |
e9576ca5 SC |
563 | } |
564 | ||
e7549107 | 565 | int wxFont::GetStyle() const |
e9576ca5 | 566 | { |
77eddfb7 | 567 | wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); |
6eaa4426 | 568 | |
e7549107 SC |
569 | return M_FONTDATA->m_style; |
570 | } | |
571 | ||
572 | int wxFont::GetWeight() const | |
573 | { | |
77eddfb7 | 574 | wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); |
6eaa4426 | 575 | |
e7549107 SC |
576 | return M_FONTDATA->m_weight; |
577 | } | |
578 | ||
579 | bool wxFont::GetUnderlined() const | |
580 | { | |
77eddfb7 | 581 | wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") ); |
6eaa4426 | 582 | |
e7549107 SC |
583 | return M_FONTDATA->m_underlined; |
584 | } | |
585 | ||
586 | wxString wxFont::GetFaceName() const | |
587 | { | |
facd6764 | 588 | wxCHECK_MSG( M_FONTDATA != NULL , wxEmptyString , wxT("invalid font") ); |
6eaa4426 | 589 | |
facd6764 | 590 | return M_FONTDATA->m_faceName; |
e7549107 SC |
591 | } |
592 | ||
593 | wxFontEncoding wxFont::GetEncoding() const | |
594 | { | |
facd6764 | 595 | wxCHECK_MSG( M_FONTDATA != NULL , wxFONTENCODING_DEFAULT , wxT("invalid font") ); |
6eaa4426 | 596 | |
e7549107 | 597 | return M_FONTDATA->m_encoding; |
e9576ca5 SC |
598 | } |
599 | ||
5ac2e80c | 600 | bool wxFont::GetNoAntiAliasing() const |
ac17f9b1 | 601 | { |
77eddfb7 | 602 | wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") ); |
6eaa4426 | 603 | |
ac17f9b1 SC |
604 | return M_FONTDATA->m_noAA; |
605 | } | |
606 | ||
facd6764 | 607 | short wxFont::MacGetFontNum() const |
fcb35beb | 608 | { |
77eddfb7 | 609 | wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); |
6eaa4426 | 610 | |
2a0155df | 611 | return M_FONTDATA->m_macFontFamily; |
fcb35beb VZ |
612 | } |
613 | ||
facd6764 | 614 | short wxFont::MacGetFontSize() const |
fcb35beb | 615 | { |
77eddfb7 | 616 | wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); |
6eaa4426 | 617 | |
fcb35beb VZ |
618 | return M_FONTDATA->m_macFontSize; |
619 | } | |
620 | ||
facd6764 | 621 | wxByte wxFont::MacGetFontStyle() const |
fcb35beb | 622 | { |
77eddfb7 | 623 | wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); |
6eaa4426 | 624 | |
fcb35beb VZ |
625 | return M_FONTDATA->m_macFontStyle; |
626 | } | |
627 | ||
facd6764 | 628 | wxUint32 wxFont::MacGetATSUFontID() const |
fcb35beb | 629 | { |
77eddfb7 | 630 | wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); |
6eaa4426 | 631 | |
fcb35beb VZ |
632 | return M_FONTDATA->m_macATSUFontID; |
633 | } | |
634 | ||
6eaa4426 | 635 | void * wxFont::MacGetATSUStyle() const |
3e527073 SC |
636 | { |
637 | wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") ); | |
6eaa4426 | 638 | |
3e527073 SC |
639 | return M_FONTDATA->m_macATSUStyle; |
640 | } | |
641 | ||
facd6764 SC |
642 | wxUint32 wxFont::MacGetATSUAdditionalQDStyles() const |
643 | { | |
77eddfb7 | 644 | wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); |
6eaa4426 | 645 | |
facd6764 SC |
646 | return M_FONTDATA->m_macATSUAdditionalQDStyles; |
647 | } | |
648 | ||
6eaa4426 | 649 | wxUint16 wxFont::MacGetThemeFontID() const |
facd6764 | 650 | { |
77eddfb7 | 651 | wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); |
6eaa4426 | 652 | |
facd6764 SC |
653 | return M_FONTDATA->m_macThemeFontID; |
654 | } | |
655 | ||
6eaa4426 | 656 | const wxNativeFontInfo * wxFont::GetNativeFontInfo() const |
3bf5a59b | 657 | { |
facd6764 | 658 | wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") ); |
3bf5a59b VZ |
659 | wxCHECK_MSG( Ok(), NULL, wxT("invalid font") ); |
660 | ||
661 | M_FONTDATA->m_info.InitFromFont(*this); | |
662 | ||
663 | return &(M_FONTDATA->m_info); | |
664 | } |