[ 1746670 ] wxGnomePrintDC::GetTextExtent() returns wrong size of text
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@47100 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1875,15 +1875,27 @@ void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxC
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) );
|
pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) );
|
||||||
|
|
||||||
int w,h;
|
int w, h;
|
||||||
pango_layout_get_pixel_size( m_layout, &w, &h );
|
pango_layout_get_pixel_size( m_layout, &w, &h );
|
||||||
|
|
||||||
|
|
||||||
if (width)
|
if (width)
|
||||||
*width = (wxCoord)(w / m_scaleX);
|
*width = (wxCoord)(w / m_scaleX);
|
||||||
if (height)
|
if (height)
|
||||||
*height = (wxCoord)(h / m_scaleY);
|
*height = (wxCoord)(h / m_scaleY);
|
||||||
|
|
||||||
if (descent)
|
if (descent)
|
||||||
{
|
{
|
||||||
PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
|
PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
|
||||||
@@ -1892,9 +1904,11 @@ void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxC
|
|||||||
*descent = h - PANGO_PIXELS(baseline);
|
*descent = h - PANGO_PIXELS(baseline);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset old font description
|
// reset unscaled size
|
||||||
if (theFont)
|
pango_font_description_set_size( desc, oldSize );
|
||||||
pango_layout_set_font_description( m_layout, m_fontdesc );
|
|
||||||
|
// reset unscaled font
|
||||||
|
pango_layout_set_font_description( m_layout, m_fontdesc );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGnomePrintDC::DoGetSize(int* width, int* height) const
|
void wxGnomePrintDC::DoGetSize(int* width, int* height) const
|
||||||
|
Reference in New Issue
Block a user