From 63c118f186f3e89fc639cdb29f447682a49f7d59 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 31 Dec 2018 00:31:02 +0100 Subject: [PATCH] Fix DPI used in wxTextCtrl::GetStyle() Using the window DPI resulted in returning a twice bigger size in points than the size really used for the windows on high-DPI monitors as, apparently, RichEdit always uses DPI of 96 internally (tested with both wxTE_RICH and wxTE_RICH2 in 192 DPI under Windows 10.0.16299.785). --- src/msw/textctrl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 8e20586ee0..4eccc2d9c6 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -3123,8 +3123,9 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) LOGFONT lf; // Convert the height from the units of 1/20th of the point in which // CHARFORMAT stores it to pixel-based units used by LOGFONT. - const wxCoord ppi = wxClientDC(this).GetPPI().y; - lf.lfHeight = wxNativeFontInfo::GetLogFontHeightAtPPI(cf.yHeight/20.0f, ppi); + // Note that RichEdit seems to always use standard DPI of 96, even when the + // window is a monitor using a higher DPI. + lf.lfHeight = wxNativeFontInfo::GetLogFontHeightAtPPI(cf.yHeight/20.0f, 96); lf.lfWidth = 0; lf.lfCharSet = ANSI_CHARSET; // FIXME: how to get correct charset? lf.lfClipPrecision = 0;