From db6f7908d01134eb2f20e9b2122d4d47456db6c9 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 20 Nov 2023 13:45:47 +0100 Subject: [PATCH] Fix cache cost on DirectWrite font engines In Qt 6, we deferred getting the ascent/descent of the font until requested. This was used to calculate the cache cost of the font engine, so as an unintended result, the DirectWrite engines were seen as extremely cheap in the font cache, and we would accumulate thousands of them before triggering a flush. The cache_cost is just a heuristic and does not need to be accurate. For most engines, we should just flush when the number of cached fonts exceed 256, so we use the basic em square of a lowercase letter as the cost here instead. Pick-to: 6.5 6.6 Change-Id: I73a65cab38adfd9ef56e436f311a7d1a2d7fbf41 Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/windows/qwindowsfontenginedirectwrite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp index a93cf16594..70cface6a1 100644 --- a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp @@ -217,7 +217,7 @@ QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite(IDWriteFontFace *di fontDef.pixelSize = pixelSize; collectMetrics(); - cache_cost = (m_ascent.toInt() + m_descent.toInt()) * m_xHeight.toInt() * 2000; + cache_cost = m_xHeight.toInt() * m_xHeight.toInt() * 2000; } QWindowsFontEngineDirectWrite::~QWindowsFontEngineDirectWrite()