wxGTK: Fixed printing to use fonts sizes adjustment consistent with wxMSW. In

particular, screen resolution no longer affects text size in printed output
when using wx's map-screen-to-paper approach to printing.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2008-09-28 09:33:04 +00:00
parent 988729f50a
commit 12ca55868c
5 changed files with 114 additions and 100 deletions

View File

@@ -1638,8 +1638,6 @@ void wxGnomePrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wx
}
}
int w,h;
pango_layout_get_pixel_size( m_layout, &w, &h );
#if 0
if ( m_backgroundMode == wxSOLID )
{
@@ -1661,6 +1659,9 @@ void wxGnomePrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wx
gs_libGnomePrint->gnome_print_pango_layout( m_gpc, m_layout );
int w,h;
pango_layout_get_pixel_size( m_layout, &w, &h );
gs_libGnomePrint->gnome_print_grestore( m_gpc );
if (underlined)
@@ -1669,7 +1670,8 @@ void wxGnomePrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wx
pango_layout_set_attributes(m_layout, NULL);
}
CalcBoundingBox (x + w, y + h);
CalcBoundingBox(x, y);
CalcBoundingBox(x + w, y + h);
}
void wxGnomePrinterDCImpl::Clear()
@@ -1687,6 +1689,10 @@ void wxGnomePrinterDCImpl::SetFont( const wxFont& font )
m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description );
float size = pango_font_description_get_size( m_fontdesc );
size = size * GetFontPointSizeAdjustment(72.0);
pango_font_description_set_size( m_fontdesc, (gint)size );
pango_layout_set_font_description( m_layout, m_fontdesc );
}
}
@@ -1914,26 +1920,24 @@ void wxGnomePrinterDCImpl::DoGetTextExtent(const wxString& string, wxCoord *widt
const wxCharBuffer dataUTF8 = string.utf8_str();
#endif
PangoFontDescription *desc = (theFont) ? theFont->GetNativeFontInfo()->description : m_fontdesc;
gint oldSize;
if ( theFont )
{
// scale the font and apply it
PangoFontDescription *desc = theFont->GetNativeFontInfo()->description;
float size = pango_font_description_get_size(desc);
size = size * GetFontPointSizeAdjustment(72.0);
pango_font_description_set_size(desc, (gint)size);
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_font_description(m_layout, desc);
}
pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) );
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);
int h;
pango_layout_get_pixel_size( m_layout, width, &h );
if ( height )
*height = h;
if (descent)
{
@@ -1943,11 +1947,14 @@ void wxGnomePrinterDCImpl::DoGetTextExtent(const wxString& string, wxCoord *widt
*descent = h - PANGO_PIXELS(baseline);
}
// reset unscaled size
pango_font_description_set_size( desc, oldSize );
if ( theFont )
{
// restore font and reset font's size back
pango_layout_set_font_description(m_layout, m_fontdesc);
// reset unscaled font
pango_layout_set_font_description( m_layout, m_fontdesc );
PangoFontDescription *desc = theFont->GetNativeFontInfo()->description;
pango_font_description_set_size(desc, oldSize);
}
}
void wxGnomePrinterDCImpl::DoGetSize(int* width, int* height) const