From baf28b5fe39ddfa8835dd3d9b8476b0cd138d0af Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 7 May 2014 15:24:50 +0000 Subject: [PATCH] Make wxGetPangoContext() work even without open display. Use default Pango font map if we don't have any default screen in wxGTK. Closes #16240. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76482 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 9626fc2567..bcde69f17a 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -285,7 +285,26 @@ PangoContext* wxGetPangoContext() g_object_ref(context); } else - context = gdk_pango_context_get_for_screen(gdk_screen_get_default()); + { + if ( GdkScreen *screen = gdk_screen_get_default() ) + { + context = gdk_pango_context_get_for_screen(screen); + } +#if PANGO_VERSION_CHECK(1,22,0) + else // No default screen. + { + // This may happen in console applications which didn't open the + // display, use the default font map for them -- it's better than + // nothing. + if (wx_pango_version_check(1,22,0) == 0) + { + context = pango_font_map_create_context( + pango_cairo_font_map_get_default ()); + } + //else: pango_font_map_create_context() not available + } +#endif // Pango 1.22+ + } return context; }