Fix units produced by wxSVGFileDC after the previous commit

Reimplement the logic of 16a02e6338 (Use DPI independent text size in
wxSVGFileDC, 2019-08-06) without using GetContentScaleFactor(), but
using wxDC::GetPPI() directly and do it under the platforms not using
logical pixels only.

This makes the units correct again in SVGs produced when using high DPI
under MSW even although wxDC::GetContentScaleFactor() now returns 1 in
this case.
This commit is contained in:
Vadim Zeitlin
2020-07-19 19:33:53 +02:00
parent 73bd293416
commit ae7a033cbd

View File

@@ -358,7 +358,13 @@ wxString CreateBrushFill(const wxBrush& brush, wxSVGShapeRenderingMode mode)
void SetScaledScreenDCFont(wxScreenDC& sDC, const wxFont& font)
{
const double scale = sDC.GetContentScaleFactor();
// When using DPI-independent pixels, the results of GetTextExtent() and
// similar don't depend on DPI anyhow.
#ifndef wxHAVE_DPI_INDEPENDENT_PIXELS
static const int SVG_DPI = 96;
const double screenDPI = sDC.GetPPI().y;
const double scale = screenDPI / SVG_DPI;
if ( scale > 1 )
{
// wxScreenDC uses the DPI of the main screen to determine the text
@@ -373,6 +379,7 @@ void SetScaledScreenDCFont(wxScreenDC& sDC, const wxFont& font)
sDC.SetFont(scaledFont);
}
else
#endif // !wxHAVE_DPI_INDEPENDENT_PIXELS
{
sDC.SetFont(font);
}