summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-11-12 14:37:42 +0100
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2014-11-13 14:38:56 +0100
commite4dabe7b30eae0642a2d7cf18a074beb7cb182ad (patch)
tree25d7e5af409f95a13cee35f345fc24b38d3da229
parent7e29781fac7f864ac80ca52be5e61c4f1a500308 (diff)
Do not force a direction before we know it
WebCore does not calculate the text direction when calculating widths the best we can do here is let the shaper guess the direction. Forcing it to the default LTR breaks HarfbuzzNG on Arabic scripts. Since the default HarfBuzz engine changed in 5.4, this was a regression from 5.3. See also https://bugs.webkit.org/show_bug.cgi?id=101440 Task-number: QTBUG-41450 Change-Id: Ia324c8e5ebd1744ce2dfaea94d5046ef1f77b483 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
-rw-r--r--Source/WebCore/platform/graphics/qt/FontQt.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/Source/WebCore/platform/graphics/qt/FontQt.cpp b/Source/WebCore/platform/graphics/qt/FontQt.cpp
index 3eead7e70..ab11c5199 100644
--- a/Source/WebCore/platform/graphics/qt/FontQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/FontQt.cpp
@@ -59,9 +59,11 @@ static const QString fromRawDataWithoutRef(const String& string, int start = 0,
return QString::fromRawData(reinterpret_cast<const QChar*>(string.characters() + start), len);
}
-static QTextLine setupLayout(QTextLayout* layout, const TextRun& style)
+static QTextLine setupLayout(QTextLayout* layout, const TextRun& style, bool shouldSetDirection)
{
- int flags = style.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight;
+ int flags = 0;
+ if (shouldSetDirection || style.directionalOverride())
+ flags |= style.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight;
if (style.expansion())
flags |= Qt::TextJustificationForced;
layout->setCacheEnabled(true);
@@ -187,7 +189,7 @@ public:
m_layout.setText(string);
m_layout.setRawFont(font.rawFont());
font.initFormatForTextLayout(&m_layout, run);
- m_line = setupLayout(&m_layout, run);
+ m_line = setupLayout(&m_layout, run, false);
}
float width(unsigned from, unsigned len, HashSet<const SimpleFontData*>* fallbackFonts)
@@ -239,7 +241,7 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float
QTextLayout layout(string);
layout.setRawFont(rawFont());
initFormatForTextLayout(&layout, run);
- QTextLine line = setupLayout(&layout, run);
+ QTextLine line = setupLayout(&layout, run, true);
const QPointF adjustedPoint(point.x(), point.y() - line.ascent());
QList<QGlyphRun> runs = line.glyphRuns(from, to - from);
@@ -263,7 +265,7 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon
QTextLayout layout(string);
layout.setRawFont(rawFont());
initFormatForTextLayout(&layout, run);
- QTextLine line = setupLayout(&layout, run);
+ QTextLine line = setupLayout(&layout, run, false);
float x1 = line.cursorToX(0);
float x2 = line.cursorToX(run.length());
float width = qAbs(x2 - x1);
@@ -279,7 +281,7 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float position, bo
QTextLayout layout(string);
layout.setRawFont(rawFont());
initFormatForTextLayout(&layout, run);
- QTextLine line = setupLayout(&layout, run);
+ QTextLine line = setupLayout(&layout, run, false);
return line.xToCursor(position);
}
@@ -291,7 +293,7 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint
QTextLayout layout(string);
layout.setRawFont(rawFont());
initFormatForTextLayout(&layout, run);
- QTextLine line = setupLayout(&layout, run);
+ QTextLine line = setupLayout(&layout, run, false);
float x1 = line.cursorToX(from);
float x2 = line.cursorToX(to);