X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6c2019b9426b21bd0eb3099afb2cb8cb901ce8b9..8403515064580b497986dcde81ac1b5b8845422f:/src/gtk1/dcclient.cpp diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 562143fe57..8a33377614 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -332,6 +332,10 @@ wxWindowDC::wxWindowDC( wxWindow *window ) #ifdef __WXGTK20__ m_context = gtk_widget_get_pango_context( widget ); + // Always take Xft context to get matching fonts + // for display and printing. + // m_context = pango_xft_get_context (GDK_DISPLAY (), DefaultScreen (GDK_DISPLAY ())); + m_fontdesc = widget->style->font_desc; #endif @@ -1422,13 +1426,19 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) x = XLOG2DEV(x); y = YLOG2DEV(y); -#if defined(__WXGTK20__) && wxUSE_WCHAR_T +#if defined(__WXGTK20__) // TODO: the layout engine should be abstracted at a higher level! PangoLayout *layout = pango_layout_new(m_context); pango_layout_set_font_description(layout, m_fontdesc); { +#if wxUSE_UNICODE const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); +#else + const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); + const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); + pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); +#endif } PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; PangoRectangle rect; @@ -1459,7 +1469,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) } #endif // GTK+ 2.0/1.x -#if defined(__WXGTK20__) && wxUSE_WCHAR_T +#if defined(__WXGTK20__) g_object_unref( G_OBJECT( layout ) ); #endif @@ -1599,10 +1609,14 @@ void wxWindowDC::DoGetTextExtent(const wxString &string, PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description; PangoLayout *layout = pango_layout_new(m_context); pango_layout_set_font_description(layout, desc); - { +#if wxUSE_UNICODE const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); - } +#else + const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); + const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); + pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); +#endif PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; PangoRectangle rect;