summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2019-12-06 07:13:28 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-04-22 16:18:57 +0200
commitf761ad3cd9ad1252f24b76ae413298dc7bed8af3 (patch)
tree0cdce90553fc85a773f3255c27024c41d1236f24 /src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h
parent7d8093df55f0bf76465add4ceb3732286971d849 (diff)
Use consistent vertical metrics on all platforms
Qt assumes that ascent+descent is the bounding height of the text, but for historical reasons, the ascent for some fonts will not contain the diacritics. On Windows, the preference is to use data from the OS/2 table which were explicitly invented to work around this, but on other platforms we are not respecting this table. This causes a text layout that looks fine on Windows to have overlapping characters on e.g. macOS. To make vertical metrics (ascent, descent, leading) consistent across all platforms, we don't blindly trust the values we get from the underlying font system, but apply in the following order: 1. If OS/2 table exists and USE_TYPO_METRICS flag is set, we use the typo metrics from OS/2 table 2. If OS/2 table exists and USE_TYPO_METRICS flag is not set, we use winAscent/winDescent from OS/2 and the line gap from HHEA table. 3. If no OS/2 table exists, we try to get ascent, descent and line gap from the HHEA table. 4. If the HHEA table does not exist (not an SFNT), we fall back to the system-provided metrics. (on macOS, we know the system-provided metrics will match the data in HHEA, so we skip parsing that table and use the data from CoreText if there is no OS/2 table). Task-number: QTBUG-80554 Change-Id: I41e6561a99513698c8e42451b4ec98bd5eb6892f Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h')
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h
index c8c6b83bf9..ccef808486 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h
@@ -99,10 +99,7 @@ public:
glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed,
const QTransform &matrix, GlyphFormat) override;
- QFixed ascent() const override;
QFixed capHeight() const override;
- QFixed descent() const override;
- QFixed leading() const override;
QFixed xHeight() const override;
qreal maxCharWidth() const override;
FaceId faceId() const override;
@@ -125,6 +122,8 @@ public:
void setUniqueFamilyName(const QString &newName) { m_uniqueFamilyName = newName; }
+ bool processHheaTable() const override;
+
private:
QImage imageForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform, const QColor &color = QColor());
void collectMetrics();
@@ -139,11 +138,8 @@ private:
QFixed m_lineThickness;
QFixed m_underlinePosition;
int m_unitsPerEm;
- QFixed m_ascent;
QFixed m_capHeight;
- QFixed m_descent;
QFixed m_xHeight;
- QFixed m_lineGap;
QFixed m_maxAdvanceWidth;
FaceId m_faceId;
QString m_uniqueFamilyName;