qt6-bb10/tests/auto/gui/text
Eskil Abrahamsen Blomfeldt 1bc78f7739 Introduce flag to use typographical line metrics for fonts
For backwards compatibility reasons, font files have multiple different
ways to specify vertical metrics (ascent, descent, etc.).

For OpenType, the main two are the usWin* and sTypo* metrics in the OS/2
font table. The usWin* metrics are typically used as the clipping bounds
of the font (so no character will ever draw outside these bounds). The
sTypo* metrics thus make it possible to specify a different set of
metrics for use in text layouts which is smaller than the clipping
bounds (or bigger), so that you can have fonts where some characters
overlap with preceding or subsequent lines.

However, GDI (and thus many applications) use usWin* also for line
spacing, which lead to the sTypo* metrics being untrustworthy in some
fonts and later to the introduction of the USE_TYPO_METRICS in the OS/2
table version 4. The idea of this flag is to tell the font system that
the sTypo* metrics can be trusted and should be preferred over the usWin*
metrics.

But the OpenType specification states that sTypo* metrics should *always*
be preferred and modern font systems such as FreeType and DirectWrite
will respect this. This in turn has lead to fonts where the
USE_TYPO_METRICS flag is untrustworthy instead, i.e. the sTypo* metrics
are preferable, but the USE_TYPO_METRICS has accidentally not been set.

Qt trusts the USE_TYPO_METRICS flag and uses the usWin* metrics whenever
this is unset. Since QFontMetricsF::height() (ascent+descent) in this
case includes the line gap metric, a lot of components have been written
to use it for size without adding any margins over the text. So changing
the default now would break a large amount of components, including the
ones in our own Windows style.

Most fonts should work correctly, by setting the USE_TYPO_METRICS flag
if the typo metrics are intended to be used. For those that do not, we
introduce a PreferTypoLineMetrics style strategy.

[ChangeLog][QtGui][Fonts] Added QFont::PreferTypoLineMetrics for using
the recommended line spacing metrics of the font, even if the font has
not explicitly set its USE_TYPO_METRICS flag.

Fixes: QTBUG-125585
Change-Id: Ib2f7df404fe719186d78733bda26da712f1ab85a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-05-31 19:30:53 +02:00
..
qabstracttextdocumentlayout Fix test compilation issues with QtLite configuration 2024-05-06 14:29:02 +00:00
qcssparser Support SVG specific stroke styling properties 2024-05-14 21:48:12 +03:00
qfont Change license for tests files 2024-02-04 09:56:42 +01:00
qfontcache Change license for tests files 2024-02-04 09:56:42 +01:00
qfontdatabase Support application fallbacks for common script 2024-05-21 07:24:03 +02:00
qfontmetrics Introduce flag to use typographical line metrics for fonts 2024-05-31 19:30:53 +02:00
qglyphrun Change license for tests files 2024-02-04 09:56:42 +01:00
qinputcontrol Change license for tests files 2024-02-04 09:56:42 +01:00
qrawfont Tests: check the output of QFile::open 2024-03-27 04:24:11 +01:00
qstatictext Change license for tests files 2024-02-04 09:56:42 +01:00
qsyntaxhighlighter Change license for tests files 2024-02-04 09:56:42 +01:00
qtextblock Change license for tests files 2024-02-04 09:56:42 +01:00
qtextcursor Fix test compilation issues with QtLite configuration 2024-05-06 14:29:02 +00:00
qtextdocument Support SVG specific stroke styling properties 2024-05-14 21:48:12 +03:00
qtextdocumentfragment QTextHtmlImporter: don't forget to appendBlock after block tag closed 2024-03-01 08:01:45 -07:00
qtextdocumentlayout Fix test compilation issues with QtLite configuration 2024-05-06 14:29:02 +00:00
qtextformat Fix test compilation issues with QtLite configuration 2024-05-06 14:29:02 +00:00
qtextimagehandler QTextDocument: Add support for responsive images 2024-05-07 12:28:59 -07:00
qtextlayout Change license for tests files 2024-02-04 09:56:42 +01:00
qtextlist Fix test compilation issues with QtLite configuration 2024-05-06 14:29:02 +00:00
qtextmarkdownimporter QTextMarkdownWriter: escape all backslashes 2024-03-26 00:47:37 -07:00
qtextmarkdownwriter Replace 'Qt Designer' and 'Qt Widgets Designer' in code 2024-05-16 13:04:41 +01:00
qtextobject Change license for tests files 2024-02-04 09:56:42 +01:00
qtextodfwriter Change license for tests files 2024-02-04 09:56:42 +01:00
qtextpiecetable Change license for tests files 2024-02-04 09:56:42 +01:00
qtextscriptengine Revert "Don't do font merging for PUA characters" 2024-03-18 09:09:07 +01:00
qtexttable Fix test compilation issues with QtLite configuration 2024-05-06 14:29:02 +00:00
CMakeLists.txt Fix test compilation issues with QtLite configuration 2024-05-06 14:29:02 +00:00