From: Robert Roebling Date: Tue, 3 Jul 2007 13:07:01 +0000 (+0000) Subject: Upport GNOME print GetTextExtent fix, X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/0cc0ce06889e28cc36bb57ad3cb7ff51863012a4 Upport GNOME print GetTextExtent fix, git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47101 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/gnome/gprint.cpp b/src/gtk/gnome/gprint.cpp index cfd57d4e64..2f7425c839 100644 --- a/src/gtk/gnome/gprint.cpp +++ b/src/gtk/gnome/gprint.cpp @@ -1860,15 +1860,27 @@ void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxC const wxCharBuffer dataUTF8 = string.utf8_str(); #endif + PangoFontDescription *desc = (theFont) ? theFont->GetNativeFontInfo()->description : m_fontdesc; + + gint oldSize = pango_font_description_get_size( desc ); + double size = oldSize; + size = size * m_scaleY; + pango_font_description_set_size( desc, (gint)size ); + + // apply scaled font + pango_layout_set_font_description( m_layout, desc ); + pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) ); - int w,h; + int w, h; pango_layout_get_pixel_size( m_layout, &w, &h ); + if (width) *width = (wxCoord)(w / m_scaleX); if (height) *height = (wxCoord)(h / m_scaleY); + if (descent) { PangoLayoutIter *iter = pango_layout_get_iter(m_layout); @@ -1877,9 +1889,11 @@ void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxC *descent = h - PANGO_PIXELS(baseline); } - // Reset old font description - if (theFont) - pango_layout_set_font_description( m_layout, m_fontdesc ); + // reset unscaled size + pango_font_description_set_size( desc, oldSize ); + + // reset unscaled font + pango_layout_set_font_description( m_layout, m_fontdesc ); } void wxGnomePrintDC::DoGetSize(int* width, int* height) const