- GdkFont *font = (GdkFont *) NULL;
-
- wxCHECK_MSG( Ok(), font, wxT("invalid font") )
-
-#ifdef __WXGTK20__
- if (*this == wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT))
- {
- font = GtkGetDefaultGuiFont();
- }
- else
- {
- PangoFontDescription *font_description = GetNativeFontInfo()->description;
-
- font = gdk_font_from_description( font_description );
- }
-#else
- long int_scale = long(scale * 100.0 + 0.5); // key for fontlist
- int point_scale = (int)((M_FONTDATA->m_pointSize * 10 * int_scale) / 100);
-
- wxNode *node = M_FONTDATA->m_scaled_xfonts.Find(int_scale);
- if (node)
- {
- font = (GdkFont*)node->Data();
- }
- else // we don't have this font in this size yet
- {
- if (*this == wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT))
- {
- font = GtkGetDefaultGuiFont();
- }
-
- if ( !font )
- {
- // do we have the XLFD?
- if ( M_FONTDATA->HasNativeFont() )
- {
- font = wxLoadFont(M_FONTDATA->m_nativeFontInfo.GetXFontName());
- }
-
- // no XLFD of no exact match - try the approximate one now
- if ( !font )
- {
- wxString xfontname;
- font = wxLoadQueryNearestFont( point_scale,
- M_FONTDATA->m_family,
- M_FONTDATA->m_style,
- M_FONTDATA->m_weight,
- M_FONTDATA->m_underlined,
- M_FONTDATA->m_faceName,
- M_FONTDATA->m_encoding,
- &xfontname);
- if ( font )
- {
- M_FONTDATA->m_nativeFontInfo.SetXFontName(xfontname);
- }
- }
- }
-
- if ( font )
- {
- M_FONTDATA->m_scaled_xfonts.Append( int_scale, (wxObject*)font );
- }
- }
-#endif // GTK 2.0
-
- // it's quite useless to make it a wxCHECK because we're going to crash
- // anyhow...
- wxASSERT_MSG( font, wxT("could not load any font?") );
-
- return font;