fixes for wxFontMapper endless recursion

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4527 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-11-12 17:00:02 +00:00
parent 741a9306b3
commit 97d3f0eee6
2 changed files with 31 additions and 14 deletions

View File

@@ -501,6 +501,22 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
{ {
wxCHECK_MSG( info, FALSE, _T("bad pointer in GetAltForEncoding") ); wxCHECK_MSG( info, FALSE, _T("bad pointer in GetAltForEncoding") );
if ( encoding == wxFONTENCODING_DEFAULT )
{
encoding = wxFont::GetDefaultEncoding();
}
// if we failed to load the system default encoding, something is really
// wrong and we'd better stop now - otherwise we will go into endless
// recursion trying to create the font in the msg box with the error
// message
if ( encoding == wxFONTENCODING_SYSTEM )
{
wxFatalError(_("can't load any font, aborting"));
// wxFatalError doesn't return
}
wxString configEntry = GetEncodingName(encoding); wxString configEntry = GetEncodingName(encoding);
// do we have a font spec for this encoding? // do we have a font spec for this encoding?

View File

@@ -61,17 +61,7 @@
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
static inline wxNativeFont wxLoadFont(const wxString& fontSpec) static inline wxNativeFont wxLoadFont(const wxString& fontSpec)
{ {
wxNativeFont font = gdk_font_load( wxConvertWX2MB(fontSpec) ); return gdk_font_load( wxConvertWX2MB(fontSpec) );
if(fontSpec == "-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
{
if(font == NULL)
font = gdk_font_load (wxConvertWX2MB("-*-*-*-*-*-*-*-*-75-*-*-*-*-*"));
if(font == NULL)
font = gdk_font_load (wxConvertWX2MB("-*-*-*-*-*-*-*-*-100-*-*-*-*-*"));
if(font == NULL)
font = gdk_font_load (wxConvertWX2MB("-*-fixed-*-*-*-*-*-*-*-*-*-*-*-*"));
}
return font;
} }
static inline void wxFreeFont(wxNativeFont font) static inline void wxFreeFont(wxNativeFont font)
@@ -228,11 +218,16 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
const wxString &facename, const wxString &facename,
wxFontEncoding encoding) wxFontEncoding encoding)
{ {
if ( encoding == wxFONTENCODING_DEFAULT )
{
encoding = wxFont::GetDefaultEncoding();
}
// first determine the encoding - if the font doesn't exist at all in this // first determine the encoding - if the font doesn't exist at all in this
// encoding, it's useless to do all other approximations (i.e. size, // encoding, it's useless to do all other approximations (i.e. size,
// family &c don't matter much) // family &c don't matter much)
wxNativeEncodingInfo info; wxNativeEncodingInfo info;
if (encoding == wxFONTENCODING_SYSTEM) if ( encoding == wxFONTENCODING_SYSTEM )
{ {
// This will always work so we don't test to save time // This will always work so we don't test to save time
wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info); wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info);
@@ -251,11 +246,10 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
// so it would provoke a crash // so it would provoke a crash
wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info); wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info);
} }
} }
} }
// OK, we have the correct xregistry/xencoding in info structure // OK, we have the correct xregistry/xencoding in info structure
wxNativeFont font = wxLoadQueryFont( pointSize, family, style, weight, wxNativeFont font = wxLoadQueryFont( pointSize, family, style, weight,
underlined, facename, underlined, facename,
info.xregistry, info.xencoding ); info.xregistry, info.xencoding );
@@ -317,6 +311,13 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
// returns TRUE if there are any fonts matching this font spec // returns TRUE if there are any fonts matching this font spec
static bool wxTestFontSpec(const wxString& fontspec) static bool wxTestFontSpec(const wxString& fontspec)
{ {
// some X servers will fail to load this font because there are too many
// matches so we must test explicitly for this
if ( fontspec == _T("-*-*-*-*-*-*-*-*-*-*-*-*-*-*") )
{
return TRUE;
}
wxNativeFont test = wxLoadFont(fontspec); wxNativeFont test = wxLoadFont(fontspec);
if ( test ) if ( test )
{ {