From 73176d2922baae1ccaa702e4900b0473071d0a96 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 3 Jul 2017 11:30:43 +0200 Subject: Add API to disable text shaping on fonts In the past, we had an undocumented text flag that worked with one of the QPainter::drawText() overloads. This was never intended as public API and served a specific cause in Qt WebKit at one point. But there is a general need for such API, as disabling shaping features easily gives 25% performance improvement on text rendering even for fairly short strings. This patch adds a new style strategy flag to disable shaping and will just uses the CMAP and HDMX tables to get glyph indices and advances for the characters. In Qt 6, the TextBypassShaping flag can be removed completely and be replaced by the style strategy. [ChangeLog][QtGui][Text] Added QFont::PreferNoShaping style strategy to support improvements to performance at the expense of some cosmetic font features. Task-number: QTBUG-56728 Change-Id: I48e025dcc06afe02824bf5b5011702a7e0036f6d Reviewed-by: Simon Hausmann --- src/gui/text/qfontmetrics.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gui/text/qfontmetrics.cpp') diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 8067969f56..5675d6921d 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -541,6 +541,7 @@ int QFontMetrics::width(const QString &text, int len, int flags) const if (len == 0) return 0; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (flags & Qt::TextBypassShaping) { // Skip complex shaping, only use advances int numGlyphs = len; @@ -554,6 +555,7 @@ int QFontMetrics::width(const QString &text, int len, int flags) const width += glyphs.advances[i]; return qRound(width); } +#endif QStackTextEngine layout(text, QFont(d.data())); return qRound(layout.width(0, len)); -- cgit v1.2.3