From 905789485a02b425356d2c9d3b4331f78aaa368e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 20 Jun 2018 14:38:45 +0200 Subject: [PATCH] Fix the just added pagination test for high DPI systems Adjust the font size used by a DPI-dependent factor to ensure that the text takes the same amount of pixels independently of DPI. --- tests/html/htmprint.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/html/htmprint.cpp b/tests/html/htmprint.cpp index 2b7f6e561a..9d805f4862 100644 --- a/tests/html/htmprint.cpp +++ b/tests/html/htmprint.cpp @@ -22,6 +22,9 @@ #include "wx/dcmemory.h" #endif // WX_PRECOMP +#include "wx/app.h" +#include "wx/window.h" + #include "wx/html/htmprint.h" namespace @@ -59,6 +62,12 @@ TEST_CASE("wxHtmlPrintout::Pagination", "[html][print]") // the DPI-dependent factor, but it doesn't seem to be worth doing it). pr.SetMargins(0, 0, 0, 0, 0); + // We do need to use DPI-proportional font sizes in order for the text used + // in the page-break-inside:avoid test to take the same amount of pixels + // for any DPI (12 being the font size used by wxHtmlDCRenderer by default). + const int adjFontSize = 12*wxTheApp->GetTopWindow()->GetContentScaleFactor(); + pr.SetStandardFonts(adjFontSize); + wxBitmap bmp(1000, 1000); wxMemoryDC dc(bmp); pr.SetUp(dc); @@ -174,6 +183,7 @@ TEST_CASE("wxHtmlPrintout::Pagination", "[html][print]") text ) ); + INFO("Using base font size " << adjFontSize); CHECK( CountPages(pr) == 3 ); }