]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: font.cpp | |
3 | // Purpose: wxFont class | |
21802234 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
21802234 | 6 | // Created: 10/06/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
21802234 DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
21802234 DW |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
7e99520b | 20 | #include <malloc.h> |
21802234 DW |
21 | // For compilers that support precompilation, includes "wx.h". |
22 | #include "wx/wxprec.h" | |
0e320a79 | 23 | |
21802234 DW |
24 | #ifndef WX_PRECOMP |
25 | #include <stdio.h> | |
26 | #include "wx/setup.h" | |
27 | #include "wx/list.h" | |
28 | #include "wx/utils.h" | |
29 | #include "wx/app.h" | |
30 | #include "wx/font.h" | |
31 | #endif // WX_PRECOMP | |
32 | ||
33 | #include "wx/os2/private.h" | |
0e320a79 | 34 | |
cc95f4f9 DW |
35 | #include "wx/fontutil.h" |
36 | #include "wx/fontmap.h" | |
37 | ||
38 | #include "wx/tokenzr.h" | |
21802234 | 39 | |
cc95f4f9 | 40 | IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) |
0e320a79 | 41 | |
21802234 DW |
42 | // ---------------------------------------------------------------------------- |
43 | // wxFontRefData - the internal description of the font | |
44 | // ---------------------------------------------------------------------------- | |
45 | ||
46 | class WXDLLEXPORT wxFontRefData: public wxGDIRefData | |
0e320a79 | 47 | { |
21802234 DW |
48 | public: |
49 | wxFontRefData() | |
50 | { | |
cc95f4f9 | 51 | Init(-1, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, FALSE, |
21802234 DW |
52 | "", wxFONTENCODING_DEFAULT); |
53 | } | |
54 | ||
e99762c0 DW |
55 | wxFontRefData( int nSize |
56 | ,int nFamily | |
57 | ,int nStyle | |
58 | ,int nWeight | |
59 | ,bool bUnderlined | |
60 | ,const wxString& sFaceName | |
61 | ,wxFontEncoding vEncoding | |
62 | ) | |
21802234 | 63 | { |
cc95f4f9 DW |
64 | Init( nSize |
65 | ,nFamily | |
66 | ,nStyle | |
67 | ,nWeight | |
68 | ,bUnderlined | |
69 | ,sFaceName | |
70 | ,vEncoding | |
71 | ); | |
72 | } | |
73 | ||
74 | wxFontRefData( const wxNativeFontInfo& rInfo | |
75 | ,WXHFONT hFont = 0 | |
76 | ,WXHANDLE hPS = 0 | |
77 | ) | |
78 | { | |
79 | Init( rInfo | |
80 | ,hFont | |
81 | ,hPS | |
82 | ); | |
83 | } | |
84 | ||
85 | wxFontRefData(const wxFontRefData& rData) | |
86 | { | |
87 | Init( rData.m_nPointSize | |
88 | ,rData.m_nFamily | |
89 | ,rData.m_nStyle | |
90 | ,rData.m_nWeight | |
91 | ,rData.m_bUnderlined | |
92 | ,rData.m_sFaceName | |
93 | ,rData.m_vEncoding | |
94 | ); | |
95 | m_nFontId = rData.m_nFontId; | |
21802234 | 96 | } |
0e320a79 | 97 | |
21802234 DW |
98 | virtual ~wxFontRefData(); |
99 | ||
cc95f4f9 DW |
100 | // |
101 | // Operations | |
102 | // | |
103 | bool Alloc(wxFont* pFont); | |
104 | void Free(void); | |
105 | ||
106 | // | |
107 | // All wxFont accessors | |
108 | // | |
109 | inline int GetPointSize(void) const | |
110 | { | |
2c1e8f2e DW |
111 | // |
112 | // We don't use the actual native font point size since it is | |
113 | // the chosen physical font, which is usually only and approximation | |
114 | // of the desired outline font. The actual displayable point size | |
115 | // is the one stored in the refData | |
116 | // | |
117 | return m_nPointSize; | |
cc95f4f9 DW |
118 | } |
119 | ||
120 | inline int GetFamily(void) const | |
121 | { | |
122 | return m_nFamily; | |
123 | } | |
124 | ||
125 | inline int GetStyle(void) const | |
126 | { | |
127 | return m_bNativeFontInfoOk ? m_vNativeFontInfo.GetStyle() | |
128 | : m_nStyle; | |
129 | } | |
130 | ||
131 | inline int GetWeight(void) const | |
132 | { | |
133 | return m_bNativeFontInfoOk ? m_vNativeFontInfo.GetWeight() | |
134 | : m_nWeight; | |
135 | } | |
136 | ||
137 | inline bool GetUnderlined(void) const | |
138 | { | |
139 | return m_bNativeFontInfoOk ? m_vNativeFontInfo.GetUnderlined() | |
140 | : m_bUnderlined; | |
141 | } | |
142 | ||
143 | inline wxString GetFaceName(void) const | |
144 | { | |
145 | wxString sFaceName; | |
146 | ||
147 | if (m_bNativeFontInfoOk) | |
148 | sFaceName = m_vNativeFontInfo.GetFaceName(); | |
149 | else | |
150 | sFaceName = m_sFaceName; | |
151 | ||
152 | return sFaceName; | |
153 | } | |
154 | ||
155 | inline wxFontEncoding GetEncoding(void) const | |
156 | { | |
157 | return m_bNativeFontInfoOk ? m_vNativeFontInfo.GetEncoding() | |
158 | : m_vEncoding; | |
159 | } | |
160 | ||
161 | inline WXHFONT GetHFONT(void) const { return m_hFont; } | |
162 | inline HPS GetPS(void) const { return m_hPS; } | |
163 | inline PFONTMETRICS GetFM(void) const { return m_pFM; } | |
164 | inline int GetNumFonts(void) const { return m_nNumFonts; } | |
165 | ||
166 | // ... and setters | |
167 | inline void SetPointSize(int nPointSize) | |
168 | { | |
169 | if (m_bNativeFontInfoOk) | |
170 | m_vNativeFontInfo.SetPointSize(nPointSize); | |
171 | else | |
172 | m_nPointSize = nPointSize; | |
173 | } | |
174 | ||
175 | inline void SetFamily(int nFamily) | |
176 | { | |
177 | m_nFamily = nFamily; | |
178 | } | |
179 | ||
180 | inline void SetStyle(int nStyle) | |
181 | { | |
182 | if (m_bNativeFontInfoOk) | |
183 | m_vNativeFontInfo.SetStyle((wxFontStyle)nStyle); | |
184 | else | |
185 | m_nStyle = nStyle; | |
186 | } | |
187 | ||
188 | inline void SetWeight(int nWeight) | |
189 | { | |
190 | if (m_bNativeFontInfoOk) | |
191 | m_vNativeFontInfo.SetWeight((wxFontWeight)nWeight); | |
192 | else | |
193 | m_nWeight = nWeight; | |
194 | } | |
195 | ||
196 | inline void SetFaceName(const wxString& sFaceName) | |
197 | { | |
198 | if (m_bNativeFontInfoOk) | |
199 | m_vNativeFontInfo.SetFaceName(sFaceName); | |
200 | else | |
201 | m_sFaceName = sFaceName; | |
202 | } | |
203 | ||
204 | inline void SetUnderlined(bool bUnderlined) | |
205 | { | |
206 | if (m_bNativeFontInfoOk) | |
207 | m_vNativeFontInfo.SetUnderlined(bUnderlined); | |
208 | else | |
209 | m_bUnderlined = bUnderlined; | |
210 | } | |
211 | ||
212 | inline void SetEncoding(wxFontEncoding vEncoding) | |
213 | { | |
214 | if (m_bNativeFontInfoOk) | |
215 | m_vNativeFontInfo.SetEncoding(vEncoding); | |
216 | else | |
217 | m_vEncoding = vEncoding; | |
218 | } | |
219 | ||
220 | inline void SetPS(HPS hPS) | |
221 | { | |
222 | m_hPS = hPS; | |
223 | } | |
224 | ||
225 | inline void SetFM(PFONTMETRICS pFM) | |
226 | { | |
227 | m_pFM = pFM; | |
228 | } | |
229 | ||
230 | inline void SetNumFonts(int nNumFonts) | |
231 | { | |
232 | m_nNumFonts = nNumFonts; | |
233 | } | |
234 | ||
235 | // | |
236 | // Native font info tests | |
237 | // | |
238 | bool HasNativeFontInfo() const { return m_bNativeFontInfoOk; } | |
239 | ||
240 | const wxNativeFontInfo& GetNativeFontInfo() const | |
241 | { return m_vNativeFontInfo; } | |
242 | ||
21802234 | 243 | protected: |
cc95f4f9 DW |
244 | // |
245 | // Common part of all ctors | |
246 | // | |
e99762c0 DW |
247 | void Init( int nSize |
248 | ,int nFamily | |
249 | ,int nStyle | |
250 | ,int nWeight | |
251 | ,bool bUnderlined | |
252 | ,const wxString& rsFaceName | |
253 | ,wxFontEncoding vEncoding | |
254 | ); | |
255 | ||
cc95f4f9 DW |
256 | void Init( const wxNativeFontInfo& rInfo |
257 | ,WXHFONT hFont = 0 | |
258 | ,WXHANDLE hPS = 0 | |
259 | ); | |
e99762c0 | 260 | // |
21802234 DW |
261 | // If TRUE, the pointer to the actual font is temporary and SHOULD NOT BE |
262 | // DELETED by destructor | |
e99762c0 DW |
263 | // |
264 | bool m_bTemporary; | |
265 | int m_nFontId; | |
266 | ||
267 | // | |
268 | // Font characterstics | |
269 | // | |
270 | int m_nPointSize; | |
271 | int m_nFamily; | |
272 | int m_nStyle; | |
273 | int m_nWeight; | |
274 | bool m_bUnderlined; | |
275 | wxString m_sFaceName; | |
276 | wxFontEncoding m_vEncoding; | |
cc95f4f9 DW |
277 | WXHFONT m_hFont; |
278 | ||
279 | // | |
280 | // Native font info | |
281 | // | |
282 | wxNativeFontInfo m_vNativeFontInfo; | |
283 | bool m_bNativeFontInfoOk; | |
e99762c0 DW |
284 | |
285 | // | |
286 | // Some PM specific stuff | |
287 | // | |
cc95f4f9 DW |
288 | PFONTMETRICS m_pFM; // array of FONTMETRICS structs |
289 | int m_nNumFonts; // number of fonts in array | |
290 | HPS m_hPS; // PS handle this font belongs to | |
291 | FATTRS m_vFattrs; // Current fattrs struct | |
292 | FACENAMEDESC m_vFname; // Current facename struct | |
293 | bool m_bInternalPS; // Internally generated PS? | |
e99762c0 | 294 | }; // end of CLASS wxFontRefData |
21802234 DW |
295 | |
296 | // ============================================================================ | |
297 | // implementation | |
298 | // ============================================================================ | |
299 | ||
300 | // ---------------------------------------------------------------------------- | |
301 | // wxFontRefData | |
302 | // ---------------------------------------------------------------------------- | |
303 | ||
e99762c0 DW |
304 | void wxFontRefData::Init( |
305 | int nPointSize | |
306 | , int nFamily | |
307 | , int nStyle | |
308 | , int nWeight | |
309 | , bool bUnderlined | |
310 | , const wxString& rsFaceName | |
311 | , wxFontEncoding vEncoding | |
312 | ) | |
0e320a79 | 313 | { |
e99762c0 DW |
314 | m_nStyle = nStyle; |
315 | m_nPointSize = nPointSize; | |
316 | m_nFamily = nFamily; | |
317 | m_nStyle = nStyle; | |
318 | m_nWeight = nWeight; | |
319 | m_bUnderlined = bUnderlined; | |
320 | m_sFaceName = rsFaceName; | |
321 | m_vEncoding = vEncoding; | |
cc95f4f9 DW |
322 | m_hFont = 0; |
323 | ||
324 | m_bNativeFontInfoOk = FALSE; | |
325 | ||
e99762c0 DW |
326 | m_nFontId = 0; |
327 | m_bTemporary = FALSE; | |
e99762c0 DW |
328 | m_pFM = (PFONTMETRICS)NULL; |
329 | m_hPS = NULLHANDLE; | |
330 | m_nNumFonts = 0; | |
331 | } // end of wxFontRefData::Init | |
0e320a79 | 332 | |
cc95f4f9 DW |
333 | void wxFontRefData::Init( |
334 | const wxNativeFontInfo& rInfo | |
335 | , WXHFONT hFont //this is the FontId -- functions as the hFont for OS/2 | |
336 | , WXHANDLE hPS // Presentation Space we are using | |
337 | ) | |
338 | { | |
339 | // | |
340 | // hFont may be zero, or it be passed in case we really want to | |
341 | // use the exact font created in the underlying system | |
342 | // (for example where we can't guarantee conversion from HFONT | |
343 | // to LOGFONT back to HFONT) | |
344 | // | |
345 | m_hFont = hFont; | |
346 | m_nFontId = (int)hFont; | |
347 | ||
348 | m_bNativeFontInfoOk = TRUE; | |
349 | m_vNativeFontInfo = rInfo; | |
350 | ||
351 | if (m_hPS == NULLHANDLE) | |
352 | { | |
353 | m_hPS = ::WinGetPS(HWND_DESKTOP); | |
07df68c8 | 354 | m_bInternalPS = TRUE; |
cc95f4f9 DW |
355 | } |
356 | else | |
357 | m_hPS = (HPS)hPS; | |
358 | } | |
359 | ||
0e320a79 | 360 | wxFontRefData::~wxFontRefData() |
cc95f4f9 DW |
361 | { |
362 | Free(); | |
363 | } | |
364 | ||
365 | bool wxFontRefData::Alloc( | |
366 | wxFont* pFont | |
367 | ) | |
368 | { | |
369 | wxString sFaceName; | |
828621c2 | 370 | long flId = m_hFont; |
e1146627 DW |
371 | long lRc; |
372 | short nIndex = 0; | |
373 | PFONTMETRICS pFM = NULL; | |
d697657f DW |
374 | ERRORID vError; |
375 | wxString sError; | |
cc95f4f9 DW |
376 | |
377 | if (!m_bNativeFontInfoOk) | |
378 | { | |
379 | wxFillLogFont( &m_vNativeFontInfo.fa | |
380 | ,&m_vNativeFontInfo.fn | |
54ffa107 | 381 | ,&m_hPS |
828621c2 | 382 | ,&m_bInternalPS |
cc95f4f9 DW |
383 | ,&flId |
384 | ,sFaceName | |
385 | ,pFont | |
386 | ); | |
387 | m_bNativeFontInfoOk = TRUE; | |
388 | } | |
07df68c8 DW |
389 | else |
390 | { | |
391 | if (flId == 0L) | |
392 | flId = 1L; | |
393 | else | |
394 | flId++; | |
395 | if (flId > 254) | |
396 | flId = 1L; | |
397 | } | |
e1146627 DW |
398 | if((lRc = ::GpiCreateLogFont( m_hPS |
399 | ,NULL | |
400 | ,flId | |
401 | ,&m_vNativeFontInfo.fa | |
402 | )) != GPI_ERROR) | |
403 | { | |
828621c2 DW |
404 | m_hFont = (WXHFONT)flId; |
405 | m_nFontId = flId; | |
e1146627 | 406 | } |
cc95f4f9 DW |
407 | if (!m_hFont) |
408 | { | |
d697657f DW |
409 | vError = ::WinGetLastError(vHabmain); |
410 | sError = wxPMErrorToStr(vError); | |
cc95f4f9 DW |
411 | wxLogLastError("CreateFont"); |
412 | } | |
413 | ||
e1146627 | 414 | ::GpiSetCharSet(m_hPS, flId); // sets font for presentation space |
cc95f4f9 DW |
415 | ::GpiQueryFontMetrics(m_hPS, sizeof(FONTMETRICS), &m_vNativeFontInfo.fm); |
416 | ||
417 | // | |
418 | // Set refData members with the results | |
419 | // | |
cc95f4f9 DW |
420 | memcpy(&m_vFattrs, &m_vNativeFontInfo.fa, sizeof(m_vFattrs)); |
421 | memcpy(&m_vFname, &m_vNativeFontInfo.fn, sizeof(m_vFname)); | |
2c1e8f2e DW |
422 | // |
423 | // Going to leave the point size alone. Mostly we use outline fonts | |
424 | // that can be set to any point size inside of Presentation Parameters, | |
425 | // regardless of whether or not the actual font is registered in the system. | |
426 | // The GpiCreateLogFont will do enough by selecting the right family, | |
427 | // and face name. | |
428 | // | |
07df68c8 | 429 | if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Times New Roman") == 0) |
cc95f4f9 | 430 | m_nFamily = wxROMAN; |
07df68c8 DW |
431 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Times New Roman MT 30") == 0) |
432 | m_nFamily = wxROMAN; | |
433 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "@Times New Roman MT 30") == 0) | |
434 | m_nFamily = wxROMAN; | |
435 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Tms Rmn") == 0) | |
436 | m_nFamily = wxROMAN; | |
437 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "WarpSans") == 0) | |
438 | m_nFamily = wxDECORATIVE; | |
439 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Helvitica") == 0) | |
e1146627 | 440 | m_nFamily = wxSWISS; |
07df68c8 | 441 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Helv") == 0) |
e1146627 | 442 | m_nFamily = wxSWISS; |
07df68c8 | 443 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Script") == 0) |
cc95f4f9 | 444 | m_nFamily = wxSCRIPT; |
07df68c8 | 445 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Courier New") == 0) |
e1146627 | 446 | m_nFamily = wxTELETYPE; |
07df68c8 | 447 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Courier") == 0) |
e1146627 | 448 | m_nFamily = wxTELETYPE; |
07df68c8 DW |
449 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "System Monospaced") == 0) |
450 | m_nFamily = wxTELETYPE; | |
451 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "System VIO") == 0) | |
452 | m_nFamily = wxTELETYPE; | |
453 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "System Proportional") == 0) | |
454 | m_nFamily = wxMODERN; | |
455 | else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Arial") == 0) | |
54ffa107 | 456 | m_nFamily = wxMODERN; |
cc95f4f9 DW |
457 | else |
458 | m_nFamily = wxSWISS; | |
459 | ||
460 | if (m_vNativeFontInfo.fa.fsSelection & FATTR_SEL_ITALIC) | |
461 | m_nStyle = wxFONTSTYLE_ITALIC; | |
462 | else | |
463 | m_nStyle = wxFONTSTYLE_NORMAL; | |
464 | switch(m_vNativeFontInfo.fn.usWeightClass) | |
465 | { | |
466 | case FWEIGHT_DONT_CARE: | |
467 | m_nWeight = wxFONTWEIGHT_NORMAL; | |
468 | break; | |
469 | ||
470 | case FWEIGHT_NORMAL: | |
471 | m_nWeight = wxFONTWEIGHT_NORMAL; | |
472 | break; | |
473 | ||
474 | case FWEIGHT_LIGHT: | |
475 | m_nWeight = wxFONTWEIGHT_LIGHT; | |
476 | break; | |
477 | ||
478 | case FWEIGHT_BOLD: | |
479 | m_nWeight = wxFONTWEIGHT_BOLD; | |
480 | break; | |
481 | ||
482 | case FWEIGHT_ULTRA_BOLD: | |
483 | m_nWeight = wxFONTWEIGHT_MAX; | |
484 | break; | |
485 | ||
486 | default: | |
487 | m_nWeight = wxFONTWEIGHT_NORMAL; | |
488 | } | |
489 | m_bUnderlined = ((m_vNativeFontInfo.fa.fsSelection & FATTR_SEL_UNDERSCORE) != 0); | |
490 | m_sFaceName = m_vNativeFontInfo.fa.szFacename; | |
491 | m_vEncoding = wxGetFontEncFromCharSet(m_vNativeFontInfo.fa.usCodePage); | |
828621c2 DW |
492 | |
493 | // | |
494 | // We don't actuall keep the font around if using a temporary PS | |
495 | // | |
496 | if (m_bInternalPS) | |
497 | { | |
498 | if(m_hFont) | |
499 | ::GpiDeleteSetId( m_hPS | |
500 | ,flId | |
501 | ); | |
502 | ||
503 | ::WinReleasePS(m_hPS); | |
504 | } | |
505 | else | |
506 | // | |
507 | // Select the font into the Presentation space | |
508 | // | |
509 | ::GpiSetCharSet(m_hPS, flId); // sets font for presentation space | |
cc95f4f9 DW |
510 | return TRUE; |
511 | } // end of wxFontRefData::Alloc | |
512 | ||
513 | void wxFontRefData::Free() | |
0e320a79 | 514 | { |
e99762c0 DW |
515 | if (m_pFM) |
516 | delete [] m_pFM; | |
517 | m_pFM = (PFONTMETRICS)NULL; | |
cc95f4f9 DW |
518 | |
519 | if ( m_hFont ) | |
520 | { | |
cc95f4f9 DW |
521 | ::GpiDeleteSetId(m_hPS, 1L); /* delete the logical font */ |
522 | m_nFontId = 0; | |
523 | m_hFont = 0; | |
524 | } | |
525 | if (m_bInternalPS) | |
526 | ::WinReleasePS(m_hPS); | |
527 | m_hPS = NULLHANDLE; | |
528 | } // end of wxFontRefData::Free | |
0e320a79 | 529 | |
21802234 | 530 | // ---------------------------------------------------------------------------- |
cc95f4f9 | 531 | // wxNativeFontInfo |
21802234 | 532 | // ---------------------------------------------------------------------------- |
0e320a79 | 533 | |
cc95f4f9 DW |
534 | void wxNativeFontInfo::Init() |
535 | { | |
536 | memset(&fa, '\0', sizeof(FATTRS)); | |
537 | } // end of wxNativeFontInfo::Init | |
538 | ||
539 | int wxNativeFontInfo::GetPointSize() const | |
540 | { | |
541 | return fm.lEmHeight; | |
542 | } // end of wxNativeFontInfo::GetPointSize | |
543 | ||
544 | wxFontStyle wxNativeFontInfo::GetStyle() const | |
545 | { | |
546 | return fa.fsSelection & FATTR_SEL_ITALIC ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL; | |
547 | } // end of wxNativeFontInfo::GetStyle | |
548 | ||
549 | wxFontWeight wxNativeFontInfo::GetWeight() const | |
550 | { | |
551 | switch(fn.usWeightClass) | |
19193a2c | 552 | { |
cc95f4f9 DW |
553 | case FWEIGHT_DONT_CARE: |
554 | return wxFONTWEIGHT_NORMAL; | |
555 | ||
556 | case FWEIGHT_NORMAL: | |
557 | return wxFONTWEIGHT_NORMAL; | |
19193a2c | 558 | |
cc95f4f9 DW |
559 | case FWEIGHT_LIGHT: |
560 | return wxFONTWEIGHT_LIGHT; | |
561 | ||
562 | case FWEIGHT_BOLD: | |
563 | return wxFONTWEIGHT_BOLD; | |
564 | ||
565 | case FWEIGHT_ULTRA_BOLD: | |
566 | return wxFONTWEIGHT_MAX; | |
19193a2c | 567 | } |
cc95f4f9 DW |
568 | return wxFONTWEIGHT_NORMAL; |
569 | } // end of wxNativeFontInfo::GetWeight | |
19193a2c | 570 | |
cc95f4f9 DW |
571 | bool wxNativeFontInfo::GetUnderlined() const |
572 | { | |
573 | return ((fa.fsSelection & FATTR_SEL_UNDERSCORE) != 0); | |
574 | } // end of wxNativeFontInfo::GetUnderlined | |
575 | ||
576 | wxString wxNativeFontInfo::GetFaceName() const | |
577 | { | |
578 | return fm.szFacename; | |
579 | } // end of wxNativeFontInfo::GetFaceName | |
580 | ||
581 | wxFontFamily wxNativeFontInfo::GetFamily() const | |
582 | { | |
583 | int nFamily; | |
584 | ||
585 | // | |
586 | // Extract family from facename | |
587 | // | |
07df68c8 DW |
588 | if (strcmp(fm.szFamilyname, "Times New Roman") == 0) |
589 | nFamily = wxROMAN; | |
590 | else if (strcmp(fm.szFamilyname, "Times New Roman MT 30") == 0) | |
591 | nFamily = wxROMAN; | |
592 | else if (strcmp(fm.szFamilyname, "@Times New Roman MT 30") == 0) | |
cc95f4f9 | 593 | nFamily = wxROMAN; |
07df68c8 DW |
594 | else if (strcmp(fm.szFamilyname, "Tms Rmn") == 0) |
595 | nFamily = wxROMAN; | |
596 | else if (strcmp(fm.szFamilyname, "WarpSans") == 0) | |
597 | nFamily = wxDECORATIVE; | |
598 | else if (strcmp(fm.szFamilyname, "Helvitica") == 0) | |
599 | nFamily = wxSWISS; | |
600 | else if (strcmp(fm.szFamilyname, "Helv") == 0) | |
cc95f4f9 | 601 | nFamily = wxSWISS; |
07df68c8 | 602 | else if (strcmp(fm.szFamilyname, "Script") == 0) |
cc95f4f9 | 603 | nFamily = wxSCRIPT; |
07df68c8 DW |
604 | else if (strcmp(fm.szFamilyname, "Courier New") == 0) |
605 | nFamily = wxTELETYPE; | |
606 | else if (strcmp(fm.szFamilyname, "Courier") == 0) | |
607 | nFamily = wxTELETYPE; | |
608 | else if (strcmp(fm.szFamilyname, "System Monospaced") == 0) | |
609 | nFamily = wxTELETYPE; | |
610 | else if (strcmp(fm.szFamilyname, "System VIO") == 0) | |
611 | nFamily = wxTELETYPE; | |
612 | else if (strcmp(fm.szFamilyname, "System Proportional") == 0) | |
613 | nFamily = wxMODERN; | |
614 | else if (strcmp(fm.szFamilyname, "Arial") == 0) | |
cc95f4f9 DW |
615 | nFamily = wxMODERN; |
616 | else | |
617 | nFamily = wxSWISS; | |
618 | return (wxFontFamily)nFamily; | |
619 | } // end of wxNativeFontInfo::GetFamily | |
620 | ||
621 | wxFontEncoding wxNativeFontInfo::GetEncoding() const | |
622 | { | |
623 | return wxGetFontEncFromCharSet(fa.usCodePage); | |
624 | } // end of wxNativeFontInfo::GetEncoding | |
625 | ||
626 | void wxNativeFontInfo::SetPointSize( | |
627 | int nPointsize | |
628 | ) | |
629 | { | |
630 | fm.lEmHeight = (LONG)nPointsize; | |
631 | } // end of wxNativeFontInfo::SetPointSize | |
632 | ||
633 | void wxNativeFontInfo::SetStyle( | |
634 | wxFontStyle eStyle | |
635 | ) | |
636 | { | |
637 | switch (eStyle) | |
638 | { | |
639 | default: | |
640 | wxFAIL_MSG( _T("unknown font style") ); | |
641 | // fall through | |
642 | ||
643 | case wxFONTSTYLE_NORMAL: | |
644 | break; | |
645 | ||
646 | case wxFONTSTYLE_ITALIC: | |
647 | case wxFONTSTYLE_SLANT: | |
648 | fa.fsSelection |= FATTR_SEL_ITALIC; | |
649 | break; | |
650 | } | |
651 | } // end of wxNativeFontInfo::SetStyle | |
652 | ||
653 | void wxNativeFontInfo::SetWeight( | |
654 | wxFontWeight eWeight | |
655 | ) | |
656 | { | |
657 | switch (eWeight) | |
658 | { | |
659 | default: | |
660 | wxFAIL_MSG( _T("unknown font weight") ); | |
661 | // fall through | |
662 | ||
663 | case wxFONTWEIGHT_NORMAL: | |
664 | fn.usWeightClass = FWEIGHT_NORMAL; | |
665 | break; | |
666 | ||
667 | case wxFONTWEIGHT_LIGHT: | |
668 | fn.usWeightClass = FWEIGHT_LIGHT; | |
669 | break; | |
670 | ||
671 | case wxFONTWEIGHT_BOLD: | |
672 | fn.usWeightClass = FWEIGHT_BOLD; | |
673 | break; | |
674 | } | |
675 | } // end of wxNativeFontInfo::SetWeight | |
676 | ||
677 | void wxNativeFontInfo::SetUnderlined( | |
678 | bool bUnderlined | |
679 | ) | |
680 | { | |
681 | if(bUnderlined) | |
682 | fa.fsSelection |= FATTR_SEL_UNDERSCORE; | |
683 | } // end of wxNativeFontInfo::SetUnderlined | |
684 | ||
685 | void wxNativeFontInfo::SetFaceName( | |
686 | wxString sFacename | |
687 | ) | |
688 | { | |
689 | wxStrncpy(fa.szFacename, sFacename, WXSIZEOF(fa.szFacename)); | |
690 | } // end of wxNativeFontInfo::SetFaceName | |
691 | ||
692 | void wxNativeFontInfo::SetFamily( | |
693 | wxFontFamily eFamily | |
694 | ) | |
695 | { | |
696 | wxString sFacename; | |
697 | ||
698 | switch (eFamily) | |
699 | { | |
700 | case wxSCRIPT: | |
07df68c8 | 701 | sFacename = wxT("Script"); |
cc95f4f9 DW |
702 | break; |
703 | ||
704 | case wxDECORATIVE: | |
07df68c8 | 705 | sFacename = wxT("WarpSans"); |
cc95f4f9 DW |
706 | break; |
707 | ||
708 | case wxROMAN: | |
07df68c8 | 709 | sFacename = wxT("Times New Roman"); |
cc95f4f9 DW |
710 | break; |
711 | ||
712 | case wxTELETYPE: | |
07df68c8 DW |
713 | sFacename = wxT("Courier New") ; |
714 | break; | |
715 | ||
cc95f4f9 | 716 | case wxMODERN: |
07df68c8 | 717 | sFacename = wxT("Arial") ; |
cc95f4f9 DW |
718 | break; |
719 | ||
720 | case wxSWISS: | |
07df68c8 | 721 | sFacename = wxT("Helv") ; |
cc95f4f9 DW |
722 | break; |
723 | ||
724 | case wxDEFAULT: | |
725 | default: | |
07df68c8 | 726 | sFacename = wxT("System Proportional") ; |
cc95f4f9 DW |
727 | } |
728 | ||
729 | if (!wxStrlen(fa.szFacename) ) | |
730 | { | |
731 | SetFaceName(sFacename); | |
732 | } | |
733 | } // end of wxNativeFontInfo::SetFamily | |
734 | ||
735 | void wxNativeFontInfo::SetEncoding( | |
736 | wxFontEncoding eEncoding | |
737 | ) | |
738 | { | |
739 | wxNativeEncodingInfo vInfo; | |
740 | ||
741 | if ( !wxGetNativeFontEncoding( eEncoding | |
742 | ,&vInfo | |
743 | )) | |
744 | { | |
142b3bc2 | 745 | if (wxFontMapper::Get()->GetAltForEncoding( eEncoding |
cc95f4f9 DW |
746 | ,&vInfo |
747 | )) | |
748 | { | |
749 | if (!vInfo.facename.empty()) | |
750 | { | |
751 | // | |
752 | // If we have this encoding only in some particular facename, use | |
753 | // the facename - it is better to show the correct characters in a | |
754 | // wrong facename than unreadable text in a correct one | |
755 | // | |
756 | SetFaceName(vInfo.facename); | |
757 | } | |
758 | } | |
759 | else | |
cc95f4f9 DW |
760 | { |
761 | // unsupported encoding, replace with the default | |
762 | vInfo.charset = 850; | |
763 | } | |
764 | } | |
765 | fa.usCodePage = vInfo.charset; | |
766 | } // end of wxNativeFontInfo::SetFaceName | |
767 | ||
768 | bool wxNativeFontInfo::FromString( | |
769 | const wxString& rsStr | |
770 | ) | |
771 | { | |
772 | long lVal; | |
773 | ||
774 | wxStringTokenizer vTokenizer(rsStr, _T(";")); | |
775 | ||
776 | // | |
777 | // First the version | |
778 | // | |
779 | wxString sToken = vTokenizer.GetNextToken(); | |
780 | ||
781 | if (sToken != _T('0')) | |
782 | return FALSE; | |
783 | ||
784 | sToken = vTokenizer.GetNextToken(); | |
785 | if (!sToken.ToLong(&lVal)) | |
786 | return FALSE; | |
787 | fm.lEmHeight = lVal; | |
788 | ||
789 | sToken = vTokenizer.GetNextToken(); | |
790 | if (!sToken.ToLong(&lVal)) | |
791 | return FALSE; | |
792 | fa.lAveCharWidth = lVal; | |
793 | ||
794 | sToken = vTokenizer.GetNextToken(); | |
795 | if (!sToken.ToLong(&lVal)) | |
796 | return FALSE; | |
797 | fa.fsSelection = (USHORT)lVal; | |
798 | ||
799 | sToken = vTokenizer.GetNextToken(); | |
800 | if (!sToken.ToLong(&lVal)) | |
801 | return FALSE; | |
802 | fa.fsType = (USHORT)lVal; | |
803 | ||
804 | sToken = vTokenizer.GetNextToken(); | |
805 | if (!sToken.ToLong(&lVal)) | |
806 | return FALSE; | |
807 | fa.fsFontUse = (USHORT)lVal; | |
808 | ||
809 | sToken = vTokenizer.GetNextToken(); | |
810 | if (!sToken.ToLong(&lVal)) | |
811 | return FALSE; | |
812 | fa.idRegistry = (USHORT)lVal; | |
813 | ||
814 | sToken = vTokenizer.GetNextToken(); | |
815 | if (!sToken.ToLong(&lVal)) | |
816 | return FALSE; | |
817 | fa.usCodePage = (USHORT)lVal; | |
818 | ||
819 | sToken = vTokenizer.GetNextToken(); | |
820 | if (!sToken.ToLong(&lVal)) | |
821 | return FALSE; | |
822 | fa.lMatch = lVal; | |
823 | ||
824 | sToken = vTokenizer.GetNextToken(); | |
825 | if (!sToken.ToLong(&lVal)) | |
826 | return FALSE; | |
827 | fn.usWeightClass = (USHORT)lVal; | |
828 | ||
829 | sToken = vTokenizer.GetNextToken(); | |
830 | if(!sToken) | |
831 | return FALSE; | |
832 | wxStrcpy(fa.szFacename, sToken.c_str()); | |
833 | return TRUE; | |
834 | } // end of wxNativeFontInfo::FromString | |
835 | ||
836 | wxString wxNativeFontInfo::ToString() const | |
837 | { | |
838 | wxString sStr; | |
839 | ||
840 | sStr.Printf(_T("%d;%ld;%ld;%ld;%d;%d;%d;%d;%d;%ld;%d;%s"), | |
841 | 0, // version, in case we want to change the format later | |
842 | fm.lEmHeight, | |
843 | fa.lAveCharWidth, | |
844 | fa.lMaxBaselineExt, | |
845 | fa.fsSelection, | |
846 | fa.fsType, | |
847 | fa.fsFontUse, | |
848 | fa.idRegistry, | |
849 | fa.usCodePage, | |
850 | fa.lMatch, | |
851 | fn.usWeightClass, | |
852 | fa.szFacename); | |
853 | return sStr; | |
854 | } // end of wxNativeFontInfo::ToString | |
855 | ||
856 | // ---------------------------------------------------------------------------- | |
857 | // wxFont | |
858 | // ---------------------------------------------------------------------------- | |
19193a2c | 859 | |
21802234 | 860 | void wxFont::Init() |
0e320a79 | 861 | { |
cc95f4f9 DW |
862 | } // end of wxFont::Init |
863 | ||
864 | bool wxFont::Create( | |
865 | const wxNativeFontInfo& rInfo | |
866 | , WXHFONT hFont | |
867 | ) | |
868 | { | |
869 | UnRef(); | |
870 | m_refData = new wxFontRefData( rInfo | |
871 | ,hFont | |
872 | ); | |
873 | RealizeResource(); | |
874 | return TRUE; | |
875 | } // end of wxFont::Create | |
876 | ||
877 | wxFont::wxFont( | |
878 | const wxString& rsFontdesc | |
879 | ) | |
880 | { | |
881 | wxNativeFontInfo vInfo; | |
882 | ||
883 | if (vInfo.FromString(rsFontdesc)) | |
884 | (void)Create(vInfo); | |
885 | } // end of wxFont::wxFont | |
0e320a79 | 886 | |
e99762c0 DW |
887 | // ---------------------------------------------------------------------------- |
888 | // Constructor for a font. Note that the real construction is done | |
889 | // in wxDC::SetFont, when information is available about scaling etc. | |
890 | // ---------------------------------------------------------------------------- | |
891 | bool wxFont::Create( | |
892 | int nPointSize | |
893 | , int nFamily | |
894 | , int nStyle | |
895 | , int nWeight | |
896 | , bool bUnderlined | |
897 | , const wxString& rsFaceName | |
898 | , wxFontEncoding vEncoding | |
899 | ) | |
0e320a79 DW |
900 | { |
901 | UnRef(); | |
cc95f4f9 DW |
902 | |
903 | // | |
904 | // wxDEFAULT is a valid value for the font size too so we must treat it | |
905 | // specially here (otherwise the size would be 70 == wxDEFAULT value) | |
906 | // | |
907 | if (nPointSize == wxDEFAULT) | |
908 | { | |
909 | nPointSize = wxNORMAL_FONT->GetPointSize(); | |
910 | } | |
e99762c0 DW |
911 | m_refData = new wxFontRefData( nPointSize |
912 | ,nFamily | |
913 | ,nStyle | |
914 | ,nWeight | |
915 | ,bUnderlined | |
916 | ,rsFaceName | |
917 | ,vEncoding | |
918 | ); | |
0e320a79 | 919 | RealizeResource(); |
0e320a79 | 920 | return TRUE; |
e99762c0 | 921 | } // end of wxFont::Create |
0e320a79 DW |
922 | |
923 | wxFont::~wxFont() | |
924 | { | |
e99762c0 | 925 | } // end of wxFont::~wxFont |
0e320a79 | 926 | |
21802234 DW |
927 | // ---------------------------------------------------------------------------- |
928 | // real implementation | |
f6bcfd97 BP |
929 | // Boris' Kovalenko comments: |
930 | // Because OS/2 fonts are associated with PS we can not create the font | |
931 | // here, but we may check that font definition is true | |
21802234 DW |
932 | // ---------------------------------------------------------------------------- |
933 | ||
0e320a79 DW |
934 | bool wxFont::RealizeResource() |
935 | { | |
21802234 DW |
936 | if ( GetResourceHandle() ) |
937 | { | |
cc95f4f9 | 938 | return TRUE; |
21802234 | 939 | } |
cc95f4f9 | 940 | return M_FONTDATA->Alloc(this); |
e99762c0 | 941 | } // end of wxFont::RealizeResource |
21802234 | 942 | |
e99762c0 DW |
943 | bool wxFont::FreeResource( |
944 | bool bForce | |
945 | ) | |
21802234 | 946 | { |
e99762c0 | 947 | if (GetResourceHandle()) |
21802234 | 948 | { |
cc95f4f9 | 949 | M_FONTDATA->Free(); |
21802234 DW |
950 | return TRUE; |
951 | } | |
0e320a79 | 952 | return FALSE; |
e99762c0 | 953 | } // end of wxFont::FreeResource |
0e320a79 | 954 | |
5fd2b2c6 DW |
955 | WXHANDLE wxFont::GetResourceHandle() |
956 | { | |
957 | return GetHFONT(); | |
e99762c0 | 958 | } // end of wxFont::GetResourceHandle |
21802234 | 959 | |
cc95f4f9 DW |
960 | WXHFONT wxFont::GetHFONT() const |
961 | { | |
962 | return M_FONTDATA ? M_FONTDATA->GetHFONT() : 0; | |
963 | } // end of wxFont::GetHFONT | |
964 | ||
21802234 DW |
965 | bool wxFont::IsFree() const |
966 | { | |
cc95f4f9 | 967 | return M_FONTDATA && (M_FONTDATA->GetHFONT() == 0); |
e99762c0 | 968 | } // end of wxFont::IsFree |
21802234 | 969 | |
0e320a79 DW |
970 | void wxFont::Unshare() |
971 | { | |
21802234 DW |
972 | // Don't change shared data |
973 | if ( !m_refData ) | |
0e320a79 | 974 | { |
21802234 DW |
975 | m_refData = new wxFontRefData(); |
976 | } | |
0e320a79 DW |
977 | else |
978 | { | |
21802234 DW |
979 | wxFontRefData* ref = new wxFontRefData(*M_FONTDATA); |
980 | UnRef(); | |
981 | m_refData = ref; | |
982 | } | |
e99762c0 | 983 | } // end of wxFont::Unshare |
0e320a79 | 984 | |
21802234 DW |
985 | // ---------------------------------------------------------------------------- |
986 | // change font attribute: we recreate font when doing it | |
987 | // ---------------------------------------------------------------------------- | |
988 | ||
e99762c0 DW |
989 | void wxFont::SetPointSize( |
990 | int nPointSize | |
991 | ) | |
0e320a79 DW |
992 | { |
993 | Unshare(); | |
994 | ||
cc95f4f9 | 995 | M_FONTDATA->SetPointSize(nPointSize); |
0e320a79 DW |
996 | |
997 | RealizeResource(); | |
e99762c0 | 998 | } // end of wxFont::SetPointSize |
0e320a79 | 999 | |
e99762c0 DW |
1000 | void wxFont::SetFamily( |
1001 | int nFamily | |
1002 | ) | |
0e320a79 DW |
1003 | { |
1004 | Unshare(); | |
1005 | ||
cc95f4f9 | 1006 | M_FONTDATA->SetFamily(nFamily); |
0e320a79 DW |
1007 | |
1008 | RealizeResource(); | |
e99762c0 | 1009 | } // end of wxFont::SetFamily |
0e320a79 | 1010 | |
e99762c0 DW |
1011 | void wxFont::SetStyle( |
1012 | int nStyle | |
1013 | ) | |
0e320a79 DW |
1014 | { |
1015 | Unshare(); | |
1016 | ||
cc95f4f9 | 1017 | M_FONTDATA->SetStyle(nStyle); |
0e320a79 DW |
1018 | |
1019 | RealizeResource(); | |
e99762c0 | 1020 | } // end of wxFont::SetStyle |
0e320a79 | 1021 | |
e99762c0 DW |
1022 | void wxFont::SetWeight( |
1023 | int nWeight | |
1024 | ) | |
0e320a79 DW |
1025 | { |
1026 | Unshare(); | |
1027 | ||
cc95f4f9 | 1028 | M_FONTDATA->SetWeight(nWeight); |
0e320a79 DW |
1029 | |
1030 | RealizeResource(); | |
e99762c0 | 1031 | } // end of wxFont::SetWeight |
0e320a79 | 1032 | |
e99762c0 DW |
1033 | void wxFont::SetFaceName( |
1034 | const wxString& rsFaceName | |
1035 | ) | |
0e320a79 DW |
1036 | { |
1037 | Unshare(); | |
1038 | ||
cc95f4f9 | 1039 | M_FONTDATA->SetFaceName(rsFaceName); |
0e320a79 DW |
1040 | |
1041 | RealizeResource(); | |
e99762c0 | 1042 | } // end of wxFont::SetFaceName |
0e320a79 | 1043 | |
e99762c0 DW |
1044 | void wxFont::SetUnderlined( |
1045 | bool bUnderlined | |
1046 | ) | |
0e320a79 DW |
1047 | { |
1048 | Unshare(); | |
1049 | ||
cc95f4f9 | 1050 | M_FONTDATA->SetUnderlined(bUnderlined); |
0e320a79 DW |
1051 | |
1052 | RealizeResource(); | |
e99762c0 | 1053 | } // end of wxFont::SetUnderlined |
0e320a79 | 1054 | |
e99762c0 DW |
1055 | void wxFont::SetEncoding( |
1056 | wxFontEncoding vEncoding | |
1057 | ) | |
0e320a79 | 1058 | { |
21802234 DW |
1059 | Unshare(); |
1060 | ||
cc95f4f9 | 1061 | M_FONTDATA->SetEncoding(vEncoding); |
21802234 DW |
1062 | |
1063 | RealizeResource(); | |
e99762c0 DW |
1064 | } // end of wxFont::SetEncoding |
1065 | ||
cc95f4f9 DW |
1066 | void wxFont::SetNativeFontInfo( |
1067 | const wxNativeFontInfo& rInfo | |
e99762c0 DW |
1068 | ) |
1069 | { | |
1070 | Unshare(); | |
1071 | ||
cc95f4f9 | 1072 | FreeResource(); |
e99762c0 | 1073 | |
cc95f4f9 | 1074 | *M_FONTDATA = wxFontRefData(rInfo); |
e99762c0 | 1075 | |
cc95f4f9 DW |
1076 | RealizeResource(); |
1077 | } | |
0e320a79 | 1078 | |
21802234 DW |
1079 | // ---------------------------------------------------------------------------- |
1080 | // accessors | |
1081 | // ---------------------------------------------------------------------------- | |
1082 | ||
1083 | int wxFont::GetPointSize() const | |
0e320a79 | 1084 | { |
cc95f4f9 | 1085 | wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); |
7e99520b | 1086 | |
cc95f4f9 | 1087 | return M_FONTDATA->GetPointSize(); |
e99762c0 | 1088 | } // end of wxFont::GetPointSize |
0e320a79 | 1089 | |
21802234 | 1090 | int wxFont::GetFamily() const |
0e320a79 | 1091 | { |
cc95f4f9 | 1092 | wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); |
21802234 | 1093 | |
cc95f4f9 DW |
1094 | return M_FONTDATA->GetFamily(); |
1095 | } // end of wxFont::GetFamily | |
21802234 DW |
1096 | |
1097 | int wxFont::GetStyle() const | |
1098 | { | |
cc95f4f9 DW |
1099 | wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); |
1100 | ||
1101 | return M_FONTDATA->GetStyle(); | |
e99762c0 | 1102 | } // end of wxFont::GetStyle |
21802234 DW |
1103 | |
1104 | int wxFont::GetWeight() const | |
1105 | { | |
cc95f4f9 DW |
1106 | wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); |
1107 | ||
1108 | return M_FONTDATA->GetWeight(); | |
21802234 DW |
1109 | } |
1110 | ||
1111 | bool wxFont::GetUnderlined() const | |
1112 | { | |
cc95f4f9 DW |
1113 | wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") ); |
1114 | ||
1115 | return M_FONTDATA->GetUnderlined(); | |
e99762c0 | 1116 | } // end of wxFont::GetUnderlined |
21802234 DW |
1117 | |
1118 | wxString wxFont::GetFaceName() const | |
1119 | { | |
cc95f4f9 | 1120 | wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") ); |
e99762c0 | 1121 | |
cc95f4f9 | 1122 | return M_FONTDATA->GetFaceName(); |
e99762c0 | 1123 | } // end of wxFont::GetFaceName |
21802234 DW |
1124 | |
1125 | wxFontEncoding wxFont::GetEncoding() const | |
1126 | { | |
cc95f4f9 | 1127 | wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); |
e99762c0 | 1128 | |
cc95f4f9 DW |
1129 | return M_FONTDATA->GetEncoding(); |
1130 | } // end of wxFont::GetEncoding | |
0e320a79 | 1131 | |
cc95f4f9 DW |
1132 | wxNativeFontInfo* wxFont::GetNativeFontInfo() const |
1133 | { | |
1134 | if (M_FONTDATA->HasNativeFontInfo()) | |
1135 | return new wxNativeFontInfo(M_FONTDATA->GetNativeFontInfo()); | |
1136 | return 0; | |
1137 | } // end of wxFont::GetNativeFontInfo | |
1138 | ||
1139 | // | |
1140 | // Internal use only method to set the FONTMETRICS array | |
1141 | // | |
1142 | void wxFont::SetFM( | |
1143 | PFONTMETRICS pFM | |
1144 | , int nNumFonts | |
1145 | ) | |
1146 | { | |
1147 | M_FONTDATA->SetFM(pFM); | |
1148 | M_FONTDATA->SetNumFonts(nNumFonts); | |
1149 | } // end of wxFont::SetFM | |
e99762c0 DW |
1150 | |
1151 | ||
d0a6b279 DW |
1152 | void wxFont::SetPS( |
1153 | HPS hPS | |
1154 | ) | |
1155 | { | |
1156 | Unshare(); | |
1157 | ||
1158 | M_FONTDATA->SetPS(hPS); | |
1159 | ||
1160 | RealizeResource(); | |
47df2b8c | 1161 | } // end of wxFont::SetPS |
d0a6b279 | 1162 |