From 7df4890d8a98d872deaebd46ca8d92473a3c6585 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 27 Feb 2012 09:51:46 +0100 Subject: Fix divide by zero when glyphWidth is 0 Change-Id: Ic0108b76b8d73cc977f8d64e036a65cb93db4684 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextengine.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 30170759a0..c63f0fede8 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2702,6 +2702,8 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end, QFixed glyphWidth = glyphs.effectiveAdvance(glyph_pos); // the approximate width of each individual element of the ligature QFixed perItemWidth = glyphWidth / clusterLength; + if (perItemWidth <= 0) + return si->position + clusterStart; QFixed left = x > edge ? edge : edge - glyphWidth; int n = ((x - left) / perItemWidth).floor().toInt(); QFixed dist = x - left - n * perItemWidth; -- cgit v1.2.3