Adjust font of wxDC to DPI of associated window
This commit is contained in:
@@ -1438,7 +1438,18 @@ void wxMSWDCImpl::DoDrawRotatedText(const wxString& text,
|
|||||||
// NB: don't take DEFAULT_GUI_FONT (a.k.a. wxSYS_DEFAULT_GUI_FONT)
|
// NB: don't take DEFAULT_GUI_FONT (a.k.a. wxSYS_DEFAULT_GUI_FONT)
|
||||||
// because it's not TrueType and so can't have non zero
|
// because it's not TrueType and so can't have non zero
|
||||||
// orientation/escapement
|
// orientation/escapement
|
||||||
wxFont font = m_font.IsOk() ? m_font : *wxSWISS_FONT;
|
wxFont font;
|
||||||
|
if ( m_font.IsOk() )
|
||||||
|
{
|
||||||
|
font = m_font;
|
||||||
|
}
|
||||||
|
else // Use default font appropriate for rotated text.
|
||||||
|
{
|
||||||
|
font = *wxSWISS_FONT;
|
||||||
|
if ( m_window )
|
||||||
|
font.WXAdjustToPPI(m_window->GetDPI());
|
||||||
|
}
|
||||||
|
|
||||||
LOGFONT lf;
|
LOGFONT lf;
|
||||||
if ( ::GetObject(GetHfontOf(font), sizeof(lf), &lf) == 0 )
|
if ( ::GetObject(GetHfontOf(font), sizeof(lf), &lf) == 0 )
|
||||||
{
|
{
|
||||||
@@ -1565,7 +1576,11 @@ void wxMSWDCImpl::SetFont(const wxFont& font)
|
|||||||
|
|
||||||
if ( font.IsOk() )
|
if ( font.IsOk() )
|
||||||
{
|
{
|
||||||
HGDIOBJ hfont = ::SelectObject(GetHdc(), GetHfontOf(font));
|
wxFont f(font);
|
||||||
|
if ( m_window )
|
||||||
|
f.WXAdjustToPPI(m_window->GetDPI());
|
||||||
|
|
||||||
|
HGDIOBJ hfont = ::SelectObject(GetHdc(), GetHfontOf(f));
|
||||||
if ( hfont == HGDI_ERROR )
|
if ( hfont == HGDI_ERROR )
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("SelectObject(font)"));
|
wxLogLastError(wxT("SelectObject(font)"));
|
||||||
@@ -1575,7 +1590,7 @@ void wxMSWDCImpl::SetFont(const wxFont& font)
|
|||||||
if ( !m_oldFont )
|
if ( !m_oldFont )
|
||||||
m_oldFont = (WXHFONT)hfont;
|
m_oldFont = (WXHFONT)hfont;
|
||||||
|
|
||||||
m_font = font;
|
m_font = f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // invalid font, reset the current font
|
else // invalid font, reset the current font
|
||||||
|
Reference in New Issue
Block a user