I am trying to scale my application written in c++ with wxWidgets for high DPI displays. I am following the guidelines in the official link. Everythings work fine so far except the return value of wxDC::GetTextExtent() function. When I move my window to a monitor with a different DPI, the font size scales but the return value of the wxDC remains the same as before. However if I use wxWindow::GetTextExtent(), it returns the correct value! In the document, it says all wxWidgets API use logical pixels but it does not seem so.
In other words, if you try to draw "text" on a device context (dc) in a high DPI display, the drawn text would be small cause the measured value of the font height by wxDC is small ( e.g does not scale ). However all other text drawn by wxWindow scales correctly.
Is this behavior intentional? what should I do to have a correct value? I am using wxWidgets 3.1.5 and Win 10.
Also it is not clear whether wxWidgets use Device Independent Pixels (DIP) or logical Pixels?
wxDC::GetTextExtent()
and wxWindow::GetTextExtent()
should return the same value and if I insert this code in the minimal sample:
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxClientDC dc(this);
wxLogMessage("wxDC: %d, wxWindow: %d",
dc.GetTextExtent("Hello").x,
GetTextExtent("Hello").x);
}
it displays "wxDC: 28, wxWindow: 28" with default DPI screen and "wxDC: 56, wxWindow: 56" when using 200% DPI scaling with wxWidgets 3.1.6, so you probably just need to update to this release.