summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <[email protected]>2022-12-14 10:03:32 +0100
committerQt Cherry-pick Bot <[email protected]>2022-12-19 10:52:34 +0000
commit124a8b6cdb3f36691cc3204d4f19e8b00975aac0 (patch)
treebe2eaa12e9103c69e35754defc1c151f4549a641
parent7520feb8f1f54e4c120d8fa90c1d4ee356e037d2 (diff)
windows: Fix vertical metrics with GDI engine
In Qt 6 we consolidated vertical font metrics across all platforms (see f761ad3cd9ad1252f24b76ae413298dc7bed8af3 and follow-ups). However, a couple mistakes were made. First of all, when we use the winAscent/winDescent values from the OS/2 table, we would also set the leading to the line gap value from the HHEA table. However, the line gap is actually built into the winAscent/winDescent, so we ended up adding this twice to the line spacing, increasing it with some older fonts. When using the Windows legacy metrics, we now set the line gap to 0 instead to reflect that this is baked into the height. In addition, since we now calculate the values ourselves, we would not round them to nearest integer like the GDI engine does. We now round these values to make it clear that the GDI engine does not support any fractional metrics. [ChangeLog][Windows][Text] Fixed an issue where the line gap of some fonts would be included twice in the font's leading. Fixes: QTBUG-109400 Change-Id: I02ab7447b5e82d9f4474f9bca581f82acee85ff3 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Lars Knoll <[email protected]> (cherry picked from commit 8892819d0c89d0434c94f0c0951458719cba5c2e) Reviewed-by: Qt Cherry-pick Bot <[email protected]>
-rw-r--r--src/gui/text/qfontengine.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 8b0dff31af7..6b764dee549 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -416,6 +416,12 @@ void QFontEngine::initializeHeightMetrics() const
// Allow OS/2 metrics to override if present
processOS2Table();
+
+ if (!supportsSubPixelPositions()) {
+ m_ascent = m_ascent.round();
+ m_descent = m_descent.round();
+ m_leading = m_leading.round();
+ }
}
m_heightMetricsQueried = true;
@@ -448,6 +454,7 @@ bool QFontEngine::processOS2Table() const
return false;
m_ascent = QFixed::fromReal(winAscent * fontDef.pixelSize) / unitsPerEm;
m_descent = QFixed::fromReal(winDescent * fontDef.pixelSize) / unitsPerEm;
+ m_leading = QFixed{};
}
return true;