summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontengine.cpp
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/gui/text/qfontengine.cpp
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/gui/text/qfontengine.cpp')
-rw-r--r--src/gui/text/qfontengine.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index c260c06fe4..9c71a073db 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -450,13 +450,14 @@ bool QFontEngine::processHheaTable() const
void QFontEngine::initializeHeightMetrics() const
{
- if (!processHheaTable()) {
- qWarning() << "Cannot determine metrics for font" << fontDef.family;
- m_ascent = m_descent = m_leading = 1;
- }
+ bool hasEmbeddedBitmaps = !getSfntTable(MAKE_TAG('E', 'B', 'L', 'C')).isEmpty() || !getSfntTable(MAKE_TAG('C', 'B', 'L', 'C')).isEmpty();
+ if (!hasEmbeddedBitmaps) {
+ // Get HHEA table values if available
+ processHheaTable();
- // Allow OS/2 metrics to override if present
- processOS2Table();
+ // Allow OS/2 metrics to override if present
+ processOS2Table();
+ }
m_heightMetricsQueried = true;
}