From c721dff3f359bc8cd64f2c91ac91076496c29b6c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 10 Dec 2021 09:18:34 +0100 Subject: [PATCH] Trust CoreText-provided vertical metrics on macOS In f761ad3cd9ad1252f24b76ae413298dc7bed8af3 we added a cross-platform consistent approach to vertical spacing of text. However, this has created problem on macOS, as some of the default fonts on the system have inconsistent metrics. Specifically, Monaco is missing the typographical metrics flag in its OS/2 table, and the alternative metrics in the table are about 30% larger than the typographical metrics (which match what is used natively). As a result, the fonts look the same on macOS as on other platforms now, but different from when the same fonts are used in native apps. We can't have fonts look wrong on their native platform, so we revert this change for CoreText, trusting the metrics we get from the system instead. We keep the consistent approach for the FreeType engine, as its main use case is cross-platform consistent text rendering. [ChangeLog][macOS][Text] Fixed an issue where certain fonts, such as Monaco, would have a different line spacing than expected. Fixes: QTBUG-97818 Change-Id: I0a3dbe4636d67779935e645066b1e51c1517dc6d Reviewed-by: Lars Knoll (cherry picked from commit b00404abffdc423c00e35ba53ca6a8bdfa91b51d) Reviewed-by: Qt Cherry-pick Bot --- src/gui/text/coretext/qfontengine_coretext.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/coretext/qfontengine_coretext.mm b/src/gui/text/coretext/qfontengine_coretext.mm index d1b13f73e91..276c0d589ea 100644 --- a/src/gui/text/coretext/qfontengine_coretext.mm +++ b/src/gui/text/coretext/qfontengine_coretext.mm @@ -371,7 +371,7 @@ void QCoreTextFontEngine::initializeHeightMetrics() const m_descent = QFixed::fromReal(CTFontGetDescent(ctfont)); m_leading = QFixed::fromReal(CTFontGetLeading(ctfont)); - QFontEngine::initializeHeightMetrics(); + m_heightMetricsQueried = true; } QFixed QCoreTextFontEngine::capHeight() const