Fix wxMSW wxWindow::GetTextExtent() with given font in high DPI
This function returned wrong results when using a non-default font in non-standard DPI because it didn't adjust the font to use the window DPI, as needs to be done manually in wxMSW before using it. Fix this now and do the same thing here as we already did in wxWindow::SetFont() (via WXAdjustFontToOwnPPI()) or in wxDC::SetFont(). See #23542. (cherry picked from commit f3a4767455f62d1a614eac6d538599ac738d3918)
This commit is contained in:
parent
82017dbc81
commit
2b19fd174f
@ -283,6 +283,7 @@ wxMSW:
|
|||||||
- Fix wxTreeCtrl::ScrollTo() with hidden root item (#23534).
|
- Fix wxTreeCtrl::ScrollTo() with hidden root item (#23534).
|
||||||
- Fix hang in wxFileDialog if COINIT_MULTITHREADED was used (#23578).
|
- Fix hang in wxFileDialog if COINIT_MULTITHREADED was used (#23578).
|
||||||
- Fix handling of RLE-compressed bitmaps (Brian Nixon, #23573).
|
- Fix handling of RLE-compressed bitmaps (Brian Nixon, #23573).
|
||||||
|
- Fix wxWindow::GetTextExtent() with given font in high DPI (#23542).
|
||||||
|
|
||||||
wxOSX:
|
wxOSX:
|
||||||
|
|
||||||
|
@ -69,8 +69,25 @@ void wxTextMeasure::BeginMeasuring()
|
|||||||
// also if we're associated with a window because the window HDC created
|
// also if we're associated with a window because the window HDC created
|
||||||
// above has the default font selected into it and not the font of the
|
// above has the default font selected into it and not the font of the
|
||||||
// window.
|
// window.
|
||||||
if ( m_font || m_win )
|
wxFont font;
|
||||||
m_hfontOld = (HFONT)::SelectObject(m_hdc, GetHfontOf(GetFont()));
|
if ( m_font )
|
||||||
|
{
|
||||||
|
font = *m_font;
|
||||||
|
|
||||||
|
// We also need to adjust this font to the DPI used by the window if
|
||||||
|
// both are given.
|
||||||
|
if ( m_win )
|
||||||
|
font.WXAdjustToPPI(m_win->GetDPI());
|
||||||
|
}
|
||||||
|
else if ( m_win )
|
||||||
|
{
|
||||||
|
// This font doesn't need DPI adjustment.
|
||||||
|
font = m_win->GetFont();
|
||||||
|
}
|
||||||
|
//else: no need to do anything when using wxDC with its default font.
|
||||||
|
|
||||||
|
if ( font.IsOk() )
|
||||||
|
m_hfontOld = (HFONT)::SelectObject(m_hdc, GetHfontOf(font));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextMeasure::EndMeasuring()
|
void wxTextMeasure::EndMeasuring()
|
||||||
|
Loading…
Reference in New Issue
Block a user