-
-// ----------------------------------------------------------------------------
-// get internal representation of font
-// ----------------------------------------------------------------------------
-
-#ifndef __WXGTK20__
-static GdkFont *g_systemDefaultGuiFont = (GdkFont*) NULL;
-
-// this is also used from tbargtk.cpp and tooltip.cpp, hence extern
-extern GdkFont *GtkGetDefaultGuiFont()
-{
- if (!g_systemDefaultGuiFont)
- {
- GtkWidget *widget = gtk_button_new();
- GtkStyle *def = gtk_rc_get_style( widget );
- if (def)
- {
- g_systemDefaultGuiFont = gdk_font_ref( def->font );
- }
- else
- {
- def = gtk_widget_get_default_style();
- if (def)
- g_systemDefaultGuiFont = gdk_font_ref( def->font );
- }
- gtk_widget_destroy( widget );
- }
- else
- {
- // already have it, but ref it once more before returning
- gdk_font_ref(g_systemDefaultGuiFont);
- }
-
- return g_systemDefaultGuiFont;
-}
-
-GdkFont *wxFont::GetInternalFont( float scale ) const
-{
- GdkFont *font = (GdkFont *) NULL;
-
- wxCHECK_MSG( Ok(), font, wxT("invalid font") )
-
- long int_scale = long(scale * 100.0 + 0.5); // key for fontlist
- int point_scale = (int)((M_FONTDATA->m_pointSize * 10 * int_scale) / 100);
-
- wxScaledFontList& list = M_FONTDATA->m_scaled_xfonts;
- wxScaledFontList::iterator i = list.find(int_scale);
- if ( i != list.end() )
- {
- font = i->second;
- }
- 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 ( int_scale == 100 && 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);
- // NB: wxFont::GetNativeFontInfo relies on this
- // side-effect of GetInternalFont
- if ( int_scale == 100 )
- M_FONTDATA->m_nativeFontInfo.SetXFontName(xfontname);
- }
- }
-
- if ( font )
- {
- list[int_scale] = font;
- }
- }
-
- // 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;
-}
-#endif // not GTK 2.0
-