summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases/mac
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-04-29 13:53:39 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-05-04 05:46:25 +0000
commit7a18b7e2c2394b2b2cc95833c755f91193d9ba2e (patch)
tree0a4f1e1905ad0d36cb3e91fd49463e5d77f5e016 /src/platformsupport/fontdatabases/mac
parentb7e3a9e5044b91322b0a64af1d110d3966c71b6b (diff)
Fix font height metrics with embedded bitmaps
For fonts with embedded bitmaps, we cannot trust the HHEA and OS/2 tables, since there are a different set of font metrics in the EBLC/CBLC tables for each of the predefined bitmap sizes. In this case, we can safely fall back to the metrics returned by the system, as the inconsistency we were originally fixing was only between OS/2 and HHEA and will not matter for the bitmap fonts. This patch also simplifies the code path through the font engines a bit. Instead of setting the system metrics in the processHheaTable() function when the table cannot be found, we instead always fetch the system metrics at the very start of initializeHeightMetrics() and then override if there are no embedded bitmaps, and if the HHEA and OS/2 tables are available. This also reduces the number of virtual functions needed to sort out the height metrics. Fixes: QTBUG-83754 Change-Id: Ib9dc6fc6cf972e48209a4a272469d2b4bd1ebffe Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/platformsupport/fontdatabases/mac')
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm12
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h2
2 files changed, 6 insertions, 8 deletions
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
index 7a6dfe266f..57fbf6032e 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -381,15 +381,13 @@ QT_WARNING_POP
return ret;
}
-bool QCoreTextFontEngine::processHheaTable() const
+void QCoreTextFontEngine::initializeHeightMetrics() const
{
- if (!QFontEngine::processHheaTable()) {
- m_ascent = QFixed::fromReal(CTFontGetAscent(ctfont));
- m_descent = QFixed::fromReal(CTFontGetDescent(ctfont));
- m_leading = QFixed::fromReal(CTFontGetLeading(ctfont));
- }
+ m_ascent = QFixed::fromReal(CTFontGetAscent(ctfont));
+ m_descent = QFixed::fromReal(CTFontGetDescent(ctfont));
+ m_leading = QFixed::fromReal(CTFontGetLeading(ctfont));
- return true;
+ QFontEngine::initializeHeightMetrics();
}
QFixed QCoreTextFontEngine::capHeight() const
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
index 5111e2ce2e..da75594fde 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
@@ -139,7 +139,7 @@ protected:
bool hasColorGlyphs() const;
bool shouldAntialias() const;
bool shouldSmoothFont() const;
- bool processHheaTable() const override;
+ void initializeHeightMetrics() const override;
QCFType<CTFontRef> ctfont;
QCFType<CGFontRef> cgFont;