From 332ed8a32fa25a12f5316bb0420284c0e3e6fe43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 14 Sep 2009 15:37:02 +0200 Subject: If the font does not exist, then the right bearing becomes to big In the QPF1 engine if the font does not exist, then the default constructor of glyph_metrics_t is used which sets the x and y values to the unlikely value of 100000. These glyph_metrics_t instances are not suppose to be used in the text layout calculations. Task-number: pending --- src/gui/text/qtextengine.cpp | 3 ++- src/gui/text/qtextengine_p.h | 1 + src/gui/text/qtextlayout.cpp | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 88837ca..b43bd06 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1645,7 +1645,8 @@ glyph_metrics_t QTextEngine::boundingBox(int from, int len) const glyph_t glyph = glyphs.glyphs[logClusters[pos + ilen - 1]]; glyph_metrics_t gi = fe->boundingBox(glyph); - gm.width -= qRound(gi.xoff - gi.x - gi.width); + if (gi.isValid()) + gm.width -= qRound(gi.xoff - gi.x - gi.width); } } return gm; diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 28ac7d9..85c6928 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -110,6 +110,7 @@ struct glyph_metrics_t QFixed yoff; glyph_metrics_t transformed(const QTransform &xform) const; + inline bool isValid() const {return x != 100000 && y != 100000;} }; Q_DECLARE_TYPEINFO(glyph_metrics_t, Q_PRIMITIVE_TYPE); diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 62795f8..f8b0cbc 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1807,7 +1807,8 @@ void QTextLine::layout_helper(int maxGlyphs) QFontEngine *fontEngine = eng->fontEngine(current); glyph_t glyph = glyphs.glyphs[logClusters[pos - 1]]; glyph_metrics_t gi = fontEngine->boundingBox(glyph); - lbh.rightBearing = -qRound(gi.xoff - gi.x - gi.width); + if (gi.isValid()) + lbh.rightBearing = -qRound(gi.xoff - gi.x - gi.width); } if ((sb_or_ws|breakany) && lbh.checkFullOtherwiseExtend(line)) { -- cgit v0.12