X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7beba2fc73283f5b750227459da57e66bcd475f5..8d0df10dcfe7c9727f3e7bd9ea3ce0f98083d658:/src/unix/fontutil.cpp?ds=sidebyside diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index c32a5acfbb..8bdd44191e 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -31,6 +31,14 @@ #ifndef WX_PRECOMP #endif // PCH +#ifdef __X__ + #include + + #include "wx/utils.h" // for wxGetDisplay() +#elif defined(__WXGTK__) + #include "gdk/gdk.h" +#endif + #include "wx/fontutil.h" #include "wx/fontmap.h" #include "wx/tokenzr.h" @@ -48,11 +56,9 @@ static inline void wxFreeFont(wxNativeFont font) { - XFreeFont((Display *)wxGetDisplay(), font); + XFreeFont((Display *)wxGetDisplay(), (XFontStruct *)font); } #elif defined(__WXGTK__) - #include "gdk/gdk.h" - static inline wxNativeFont wxLoadFont(const wxString& fontSpec) { return gdk_font_load( wxConvertWX2MB(fontSpec) ); @@ -178,7 +184,7 @@ bool wxGetNativeFontEncoding(wxFontEncoding encoding, case wxFONTENCODING_SYSTEM: info->xregistry = - info->xencoding = wxT('*'); + info->xencoding = wxT("*"); break; default: @@ -216,20 +222,29 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize, // encoding, it's useless to do all other approximations (i.e. size, // family &c don't matter much) wxNativeEncodingInfo info; - if ( !wxGetNativeFontEncoding(encoding, &info) || - !wxTestFontEncoding(info) ) + if (encoding == wxFONTENCODING_SYSTEM) + { + // This will always work so we don't test to save time + wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info); + } + else { - if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) ) + if ( !wxGetNativeFontEncoding(encoding, &info) || + !wxTestFontEncoding(info) ) { - // unspported encoding - replace it with the default - // - // NB: we can't just return 0 from here because wxGTK code doesn't - // check for it (i.e. it supposes that we'll always succeed), - // so it would provoke a crash - wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info); - } + if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) ) + { + // unspported encoding - replace it with the default + // + // NB: we can't just return 0 from here because wxGTK code doesn't + // check for it (i.e. it supposes that we'll always succeed), + // so it would provoke a crash + wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info); + } + } } - //else: 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, underlined, facename,