Include wx/cmndata.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / gtk1 / font.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/font.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling and Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // ============================================================================
11 // declarations
12 // ============================================================================
13
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17
18 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
20
21 #include "wx/font.h"
22
23 #ifndef WX_PRECOMP
24 #include "wx/log.h"
25 #include "wx/settings.h"
26 #include "wx/cmndata.h"
27 #endif
28
29 #include "wx/fontutil.h"
30 #include "wx/utils.h"
31 #include "wx/gdicmn.h"
32 #include "wx/tokenzr.h"
33
34 #include <strings.h>
35
36 #include "wx/gtk1/private.h"
37 #include <gdk/gdkprivate.h>
38
39 // ----------------------------------------------------------------------------
40 // constants
41 // ----------------------------------------------------------------------------
42
43 // the default size (in points) for the fonts
44 static const int wxDEFAULT_FONT_SIZE = 12;
45
46 // ----------------------------------------------------------------------------
47 // wxScaledFontList: maps the font sizes to the GDK fonts for the given font
48 // ----------------------------------------------------------------------------
49
50 WX_DECLARE_HASH_MAP(int, GdkFont *, wxIntegerHash, wxIntegerEqual,
51 wxScaledFontList);
52
53 // ----------------------------------------------------------------------------
54 // wxFontRefData
55 // ----------------------------------------------------------------------------
56
57 class wxFontRefData : public wxObjectRefData
58 {
59 public:
60 // from broken down font parameters, also default ctor
61 wxFontRefData(int size = -1,
62 int family = wxFONTFAMILY_DEFAULT,
63 int style = wxFONTSTYLE_NORMAL,
64 int weight = wxFONTWEIGHT_NORMAL,
65 bool underlined = false,
66 const wxString& faceName = wxEmptyString,
67 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
68
69 // from XFLD
70 wxFontRefData(const wxString& fontname);
71
72 // copy ctor
73 wxFontRefData( const wxFontRefData& data );
74
75 virtual ~wxFontRefData();
76
77 // do we have the native font info?
78 bool HasNativeFont() const
79 {
80 // only use m_nativeFontInfo if it had been initialized
81 return !m_nativeFontInfo.IsDefault();
82 }
83
84 // setters: all of them also take care to modify m_nativeFontInfo if we
85 // have it so as to not lose the information not carried by our fields
86 void SetPointSize(int pointSize);
87 void SetFamily(int family);
88 void SetStyle(int style);
89 void SetWeight(int weight);
90 void SetUnderlined(bool underlined);
91 void SetFaceName(const wxString& facename);
92 void SetEncoding(wxFontEncoding encoding);
93
94 void SetNoAntiAliasing( bool no = true ) { m_noAA = no; }
95 bool GetNoAntiAliasing() const { return m_noAA; }
96
97 // and this one also modifies all the other font data fields
98 void SetNativeFontInfo(const wxNativeFontInfo& info);
99
100 // debugger helper: shows what the font really is
101 //
102 // VZ: I need this as my gdb either shows wildly wrong values or crashes
103 // when I ask it to "p fontRefData" :-(
104 #if defined(__WXDEBUG__)
105 void Dump() const
106 {
107 wxPrintf(_T("%s-%s-%s-%d-%d\n"),
108 m_faceName.c_str(),
109 m_weight == wxFONTWEIGHT_NORMAL
110 ? _T("normal")
111 : m_weight == wxFONTWEIGHT_BOLD
112 ? _T("bold")
113 : _T("light"),
114 m_style == wxFONTSTYLE_NORMAL ? _T("regular") : _T("italic"),
115 m_pointSize,
116 m_encoding);
117 }
118 #endif // Debug
119
120 protected:
121 // common part of all ctors
122 void Init(int pointSize,
123 int family,
124 int style,
125 int weight,
126 bool underlined,
127 const wxString& faceName,
128 wxFontEncoding encoding);
129
130 // set all fields from (already initialized and valid) m_nativeFontInfo
131 void InitFromNative();
132
133 private:
134 // clear m_scaled_xfonts if any
135 void ClearGdkFonts();
136
137 // the map of font sizes to "GdkFont *"
138 wxScaledFontList m_scaled_xfonts;
139
140 int m_pointSize;
141 int m_family,
142 m_style,
143 m_weight;
144 bool m_underlined;
145 wxString m_faceName;
146 wxFontEncoding m_encoding; // Unused under GTK 2.0
147 bool m_noAA; // No anti-aliasing
148
149 // The native font info, basicly an XFLD under GTK 1.2 and
150 // the pango font description under GTK 2.0.
151 wxNativeFontInfo m_nativeFontInfo;
152
153 friend class wxFont;
154 };
155
156 // ----------------------------------------------------------------------------
157 // wxFontRefData
158 // ----------------------------------------------------------------------------
159
160 void wxFontRefData::Init(int pointSize,
161 int family,
162 int style,
163 int weight,
164 bool underlined,
165 const wxString& faceName,
166 wxFontEncoding encoding)
167 {
168 m_family = family == wxFONTFAMILY_DEFAULT ? wxFONTFAMILY_SWISS : family;
169
170 m_faceName = faceName;
171
172 // we accept both wxDEFAULT and wxNORMAL here - should we?
173 m_style = style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style;
174 m_weight = weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight;
175
176 // and here, do we really want to forbid creation of the font of the size
177 // 90 (the value of wxDEFAULT)??
178 m_pointSize = pointSize == wxDEFAULT || pointSize == -1
179 ? wxDEFAULT_FONT_SIZE
180 : pointSize;
181
182 m_underlined = underlined;
183 m_encoding = encoding;
184
185 m_noAA = false;
186 }
187
188 void wxFontRefData::InitFromNative()
189 {
190 m_noAA = false;
191
192 // get the font parameters from the XLFD
193 // -------------------------------------
194
195 m_faceName = m_nativeFontInfo.GetXFontComponent(wxXLFD_FAMILY);
196
197 m_weight = wxFONTWEIGHT_NORMAL;
198
199 wxString w = m_nativeFontInfo.GetXFontComponent(wxXLFD_WEIGHT).Upper();
200 if ( !w.empty() && w != _T('*') )
201 {
202 // the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD
203 // and BLACK
204 if ( ((w[0u] == _T('B') && (!wxStrcmp(w.c_str() + 1, wxT("OLD")) ||
205 !wxStrcmp(w.c_str() + 1, wxT("LACK"))))) ||
206 wxStrstr(w.c_str() + 1, _T("BOLD")) )
207 {
208 m_weight = wxFONTWEIGHT_BOLD;
209 }
210 else if ( w == _T("LIGHT") || w == _T("THIN") )
211 {
212 m_weight = wxFONTWEIGHT_LIGHT;
213 }
214 }
215
216 switch ( wxToupper(*m_nativeFontInfo.
217 GetXFontComponent(wxXLFD_SLANT).c_str()) )
218 {
219 case _T('I'): // italique
220 m_style = wxFONTSTYLE_ITALIC;
221 break;
222
223 case _T('O'): // oblique
224 m_style = wxFONTSTYLE_SLANT;
225 break;
226
227 default:
228 m_style = wxFONTSTYLE_NORMAL;
229 }
230
231 long ptSize;
232 if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_POINTSIZE).ToLong(&ptSize) )
233 {
234 // size in XLFD is in 10 point units
235 m_pointSize = (int)(ptSize / 10);
236 }
237 else
238 {
239 m_pointSize = wxDEFAULT_FONT_SIZE;
240 }
241
242 // examine the spacing: if the font is monospaced, assume wxTELETYPE
243 // family for compatibility with the old code which used it instead of
244 // IsFixedWidth()
245 if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == _T('M') )
246 {
247 m_family = wxFONTFAMILY_TELETYPE;
248 }
249 else // not monospaceed
250 {
251 // don't even try guessing it, it doesn't work for too many fonts
252 // anyhow
253 m_family = wxFONTFAMILY_UNKNOWN;
254 }
255
256 // X fonts are never underlined...
257 m_underlined = false;
258
259 // deal with font encoding
260 wxString
261 registry = m_nativeFontInfo.GetXFontComponent(wxXLFD_REGISTRY).Upper(),
262 encoding = m_nativeFontInfo.GetXFontComponent(wxXLFD_ENCODING).Upper();
263
264 if ( registry == _T("ISO8859") )
265 {
266 int cp;
267 if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 )
268 {
269 m_encoding = (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1);
270 }
271 }
272 else if ( registry == _T("MICROSOFT") )
273 {
274 int cp;
275 if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 )
276 {
277 m_encoding = (wxFontEncoding)(wxFONTENCODING_CP1250 + cp);
278 }
279 }
280 else if ( registry == _T("KOI8") )
281 {
282 m_encoding = wxFONTENCODING_KOI8;
283 }
284 else // unknown encoding
285 {
286 // may be give a warning here? or use wxFontMapper?
287 m_encoding = wxFONTENCODING_SYSTEM;
288 }
289 }
290
291 wxFontRefData::wxFontRefData( const wxFontRefData& data )
292 : wxObjectRefData()
293 {
294 m_pointSize = data.m_pointSize;
295 m_family = data.m_family;
296 m_style = data.m_style;
297 m_weight = data.m_weight;
298
299 m_underlined = data.m_underlined;
300
301 m_faceName = data.m_faceName;
302 m_encoding = data.m_encoding;
303
304 m_noAA = data.m_noAA;
305
306 // Forces a copy of the internal data. wxNativeFontInfo should probably
307 // have a copy ctor and assignment operator to fix this properly but that
308 // would break binary compatibility...
309 m_nativeFontInfo.FromString(data.m_nativeFontInfo.ToString());
310 }
311
312 wxFontRefData::wxFontRefData(int size, int family, int style,
313 int weight, bool underlined,
314 const wxString& faceName,
315 wxFontEncoding encoding)
316 {
317 Init(size, family, style, weight, underlined, faceName, encoding);
318 }
319
320 wxFontRefData::wxFontRefData(const wxString& fontname)
321 {
322 // FromString() should really work in GTK1 too, doesn't it?
323 m_nativeFontInfo.SetXFontName(fontname);
324
325 InitFromNative();
326 }
327
328 void wxFontRefData::ClearGdkFonts()
329 {
330 for ( wxScaledFontList::iterator i = m_scaled_xfonts.begin();
331 i != m_scaled_xfonts.end();
332 ++i )
333 {
334 GdkFont *font = i->second;
335 gdk_font_unref( font );
336 }
337
338 m_scaled_xfonts.clear();
339 }
340
341 wxFontRefData::~wxFontRefData()
342 {
343 ClearGdkFonts();
344 }
345
346 // ----------------------------------------------------------------------------
347 // wxFontRefData SetXXX()
348 // ----------------------------------------------------------------------------
349
350 void wxFontRefData::SetPointSize(int pointSize)
351 {
352 m_pointSize = pointSize;
353
354 if ( HasNativeFont() )
355 {
356 wxString size;
357 if ( pointSize == -1 )
358 size = _T('*');
359 else
360 size.Printf(_T("%d"), 10*pointSize);
361
362 m_nativeFontInfo.SetXFontComponent(wxXLFD_POINTSIZE, size);
363 }
364 }
365
366 void wxFontRefData::SetFamily(int family)
367 {
368 m_family = family;
369
370 // TODO: what are we supposed to do with m_nativeFontInfo here?
371 }
372
373 void wxFontRefData::SetStyle(int style)
374 {
375 m_style = style;
376
377 if ( HasNativeFont() )
378 {
379 wxString slant;
380 switch ( style )
381 {
382 case wxFONTSTYLE_ITALIC:
383 slant = _T('i');
384 break;
385
386 case wxFONTSTYLE_SLANT:
387 slant = _T('o');
388 break;
389
390 default:
391 wxFAIL_MSG( _T("unknown font style") );
392 // fall through
393
394 case wxFONTSTYLE_NORMAL:
395 slant = _T('r');
396 }
397
398 m_nativeFontInfo.SetXFontComponent(wxXLFD_SLANT, slant);
399 }
400 }
401
402 void wxFontRefData::SetWeight(int weight)
403 {
404 m_weight = weight;
405
406 if ( HasNativeFont() )
407 {
408 wxString boldness;
409 switch ( weight )
410 {
411 case wxFONTWEIGHT_BOLD:
412 boldness = _T("bold");
413 break;
414
415 case wxFONTWEIGHT_LIGHT:
416 boldness = _T("light");
417 break;
418
419 default:
420 wxFAIL_MSG( _T("unknown font weight") );
421 // fall through
422
423 case wxFONTWEIGHT_NORMAL:
424 // unspecified
425 boldness = _T("medium");
426 }
427
428 m_nativeFontInfo.SetXFontComponent(wxXLFD_WEIGHT, boldness);
429 }
430 }
431
432 void wxFontRefData::SetUnderlined(bool underlined)
433 {
434 m_underlined = underlined;
435
436 // the XLFD doesn't have "underlined" field anyhow
437 }
438
439 void wxFontRefData::SetFaceName(const wxString& facename)
440 {
441 m_faceName = facename;
442
443 if ( HasNativeFont() )
444 {
445 m_nativeFontInfo.SetXFontComponent(wxXLFD_FAMILY, facename);
446 }
447 }
448
449 void wxFontRefData::SetEncoding(wxFontEncoding encoding)
450 {
451 m_encoding = encoding;
452
453 if ( HasNativeFont() )
454 {
455 wxNativeEncodingInfo info;
456 if ( wxGetNativeFontEncoding(encoding, &info) )
457 {
458 m_nativeFontInfo.SetXFontComponent(wxXLFD_REGISTRY, info.xregistry);
459 m_nativeFontInfo.SetXFontComponent(wxXLFD_ENCODING, info.xencoding);
460 }
461 }
462 }
463
464 void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info)
465 {
466 // previously cached fonts shouldn't be used
467 ClearGdkFonts();
468
469 m_nativeFontInfo = info;
470
471 // set all the other font parameters from the native font info
472 InitFromNative();
473 }
474
475 // ----------------------------------------------------------------------------
476 // wxFont creation
477 // ----------------------------------------------------------------------------
478
479 IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
480
481 wxFont::wxFont(const wxNativeFontInfo& info)
482 {
483 (void) Create(info.GetXFontName());
484 }
485
486 bool wxFont::Create( int pointSize,
487 int family,
488 int style,
489 int weight,
490 bool underlined,
491 const wxString& face,
492 wxFontEncoding encoding)
493 {
494 UnRef();
495
496 m_refData = new wxFontRefData(pointSize, family, style, weight,
497 underlined, face, encoding);
498
499 return true;
500 }
501
502 bool wxFont::Create(const wxString& fontname)
503 {
504 // VZ: does this really happen?
505 if ( fontname.empty() )
506 {
507 *this = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
508
509 return true;
510 }
511
512 m_refData = new wxFontRefData(fontname);
513
514 return true;
515 }
516
517 void wxFont::Unshare()
518 {
519 if (!m_refData)
520 {
521 m_refData = new wxFontRefData();
522 }
523 else
524 {
525 wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
526 UnRef();
527 m_refData = ref;
528 }
529 }
530
531 wxFont::~wxFont()
532 {
533 }
534
535 // ----------------------------------------------------------------------------
536 // accessors
537 // ----------------------------------------------------------------------------
538
539 int wxFont::GetPointSize() const
540 {
541 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
542
543 #if wxUSE_PANGO
544 return M_FONTDATA->HasNativeFont() ? M_FONTDATA->m_nativeFontInfo.GetPointSize()
545 : M_FONTDATA->m_pointSize;
546 #else
547 return M_FONTDATA->m_pointSize;
548 #endif
549 }
550
551 wxString wxFont::GetFaceName() const
552 {
553 wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") );
554
555 #if wxUSE_PANGO
556 return M_FONTDATA->HasNativeFont() ? M_FONTDATA->m_nativeFontInfo.GetFaceName()
557 : M_FONTDATA->m_faceName;
558 #else
559 return M_FONTDATA->m_faceName;
560 #endif
561 }
562
563 int wxFont::GetFamily() const
564 {
565 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
566
567 #if wxUSE_PANGO
568 int ret = M_FONTDATA->m_family;
569 if (M_FONTDATA->HasNativeFont())
570 // wxNativeFontInfo::GetFamily is expensive, must not call more than once
571 ret = M_FONTDATA->m_nativeFontInfo.GetFamily();
572
573 if (ret == wxFONTFAMILY_DEFAULT)
574 ret = M_FONTDATA->m_family;
575
576 return ret;
577 #else
578 return M_FONTDATA->m_family;
579 #endif
580 }
581
582 int wxFont::GetStyle() const
583 {
584 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
585
586 #if wxUSE_PANGO
587 return M_FONTDATA->HasNativeFont() ? M_FONTDATA->m_nativeFontInfo.GetStyle()
588 : M_FONTDATA->m_style;
589 #else
590 return M_FONTDATA->m_style;
591 #endif
592 }
593
594 int wxFont::GetWeight() const
595 {
596 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
597
598 #if wxUSE_PANGO
599 return M_FONTDATA->HasNativeFont() ? M_FONTDATA->m_nativeFontInfo.GetWeight()
600 : M_FONTDATA->m_weight;
601 #else
602 return M_FONTDATA->m_weight;
603 #endif
604 }
605
606 bool wxFont::GetUnderlined() const
607 {
608 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
609
610 return M_FONTDATA->m_underlined;
611 }
612
613 wxFontEncoding wxFont::GetEncoding() const
614 {
615 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
616
617 // m_encoding is unused in wxGTK2, return encoding that the user set.
618 return M_FONTDATA->m_encoding;
619 }
620
621 bool wxFont::GetNoAntiAliasing() const
622 {
623 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
624
625 return M_FONTDATA->m_noAA;
626 }
627
628 const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
629 {
630 wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
631
632 if ( !M_FONTDATA->HasNativeFont() )
633 {
634 // NB: this call has important side-effect: it not only finds
635 // GdkFont representation, it also initializes m_nativeFontInfo
636 // by calling its SetXFontName method
637 GetInternalFont();
638 }
639
640 return &(M_FONTDATA->m_nativeFontInfo);
641 }
642
643 bool wxFont::IsFixedWidth() const
644 {
645 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
646
647 if ( M_FONTDATA->HasNativeFont() )
648 {
649 // the monospace fonts are supposed to have "M" in the spacing field
650 wxString spacing = M_FONTDATA->
651 m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING);
652
653 return spacing.Upper() == _T('M');
654 }
655
656 return wxFontBase::IsFixedWidth();
657 }
658
659 // ----------------------------------------------------------------------------
660 // change font attributes
661 // ----------------------------------------------------------------------------
662
663 void wxFont::SetPointSize(int pointSize)
664 {
665 Unshare();
666
667 M_FONTDATA->SetPointSize(pointSize);
668 }
669
670 void wxFont::SetFamily(int family)
671 {
672 Unshare();
673
674 M_FONTDATA->SetFamily(family);
675 }
676
677 void wxFont::SetStyle(int style)
678 {
679 Unshare();
680
681 M_FONTDATA->SetStyle(style);
682 }
683
684 void wxFont::SetWeight(int weight)
685 {
686 Unshare();
687
688 M_FONTDATA->SetWeight(weight);
689 }
690
691 void wxFont::SetFaceName(const wxString& faceName)
692 {
693 Unshare();
694
695 M_FONTDATA->SetFaceName(faceName);
696 }
697
698 void wxFont::SetUnderlined(bool underlined)
699 {
700 Unshare();
701
702 M_FONTDATA->SetUnderlined(underlined);
703 }
704
705 void wxFont::SetEncoding(wxFontEncoding encoding)
706 {
707 Unshare();
708
709 M_FONTDATA->SetEncoding(encoding);
710 }
711
712 void wxFont::DoSetNativeFontInfo( const wxNativeFontInfo& info )
713 {
714 Unshare();
715
716 M_FONTDATA->SetNativeFontInfo( info );
717 }
718
719 void wxFont::SetNoAntiAliasing( bool no )
720 {
721 Unshare();
722
723 M_FONTDATA->SetNoAntiAliasing( no );
724 }
725
726 // ----------------------------------------------------------------------------
727 // get internal representation of font
728 // ----------------------------------------------------------------------------
729
730 static GdkFont *g_systemDefaultGuiFont = (GdkFont*) NULL;
731
732 // this is also used from tbargtk.cpp and tooltip.cpp, hence extern
733 extern GdkFont *GtkGetDefaultGuiFont()
734 {
735 if (!g_systemDefaultGuiFont)
736 {
737 GtkWidget *widget = gtk_button_new();
738 GtkStyle *def = gtk_rc_get_style( widget );
739 if (def)
740 {
741 g_systemDefaultGuiFont = gdk_font_ref( def->font );
742 }
743 else
744 {
745 def = gtk_widget_get_default_style();
746 if (def)
747 g_systemDefaultGuiFont = gdk_font_ref( def->font );
748 }
749 gtk_widget_destroy( widget );
750 }
751 else
752 {
753 // already have it, but ref it once more before returning
754 gdk_font_ref(g_systemDefaultGuiFont);
755 }
756
757 return g_systemDefaultGuiFont;
758 }
759
760 GdkFont *wxFont::GetInternalFont( float scale ) const
761 {
762 GdkFont *font = (GdkFont *) NULL;
763
764 wxCHECK_MSG( Ok(), font, wxT("invalid font") );
765
766 long int_scale = long(scale * 100.0 + 0.5); // key for fontlist
767 int point_scale = (int)((M_FONTDATA->m_pointSize * 10 * int_scale) / 100);
768
769 wxScaledFontList& list = M_FONTDATA->m_scaled_xfonts;
770 wxScaledFontList::iterator i = list.find(int_scale);
771 if ( i != list.end() )
772 {
773 font = i->second;
774 }
775 else // we don't have this font in this size yet
776 {
777 if (*this == wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT))
778 {
779 font = GtkGetDefaultGuiFont();
780 }
781
782 if ( !font )
783 {
784 // do we have the XLFD?
785 if ( int_scale == 100 && M_FONTDATA->HasNativeFont() )
786 {
787 font = wxLoadFont(M_FONTDATA->m_nativeFontInfo.GetXFontName());
788 }
789
790 // no XLFD of no exact match - try the approximate one now
791 if ( !font )
792 {
793 wxString xfontname;
794 font = wxLoadQueryNearestFont( point_scale,
795 M_FONTDATA->m_family,
796 M_FONTDATA->m_style,
797 M_FONTDATA->m_weight,
798 M_FONTDATA->m_underlined,
799 M_FONTDATA->m_faceName,
800 M_FONTDATA->m_encoding,
801 &xfontname);
802 // NB: wxFont::GetNativeFontInfo relies on this
803 // side-effect of GetInternalFont
804 if ( int_scale == 100 )
805 M_FONTDATA->m_nativeFontInfo.SetXFontName(xfontname);
806 }
807 }
808
809 if ( font )
810 {
811 list[int_scale] = font;
812 }
813 }
814
815 // it's quite useless to make it a wxCHECK because we're going to crash
816 // anyhow...
817 wxASSERT_MSG( font, wxT("could not load any font?") );
818
819 return font;
820 }