]> Git trees. - libqmvoc.git/commitdiff
Fix font size calculation v4.5.80
authorChristoph Feck <christoph@maxiom.de>
Fri, 29 Oct 2010 00:43:02 +0000 (00:43 +0000)
committerChristoph Feck <christoph@maxiom.de>
Fri, 29 Oct 2010 00:43:02 +0000 (00:43 +0000)
Use a brute force method to handle the word wrapped texts
that are used by kanagram. Also make the hint text box
slightly taller to center better and have more room.

BUG: 219473

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=1190821

kdeeduui/kedufontutils.cpp

index b75be7d06b5a1947c03b48b6109885bdf93a0c53..39ae6f37aa086e34424c75dd9ffaafa48df59df6 100644 (file)
@@ -28,7 +28,15 @@ int fontUtils::fontSize(QPainter &p, const QString &s1, int w, int h, Flags flag
         if (flags & DoNotAllowWordWrap) qtFlags = qtFlags & ~Qt::TextWordWrap;
         aux1 = p.boundingRect(QRect(0, 0, w, h), qtFlags, s1);
         if (aux1.width() == 0 || aux1.height() == 0) return -1;
-        else if (aux1.width() > w || aux1.height() > h) size = qMin(w * size / aux1.width(), h * size / aux1.height());
+        else if (aux1.width() > w || aux1.height() > h) {
+            if (flags & DoNotAllowWordWrap || aux1.height() == p.fontMetrics().height()) {
+                size = qMin(w * size / aux1.width(), h * size / aux1.height());
+            } else {
+                // Word wrapping can completely change the
+                // layout of the text, so the above will not work.
+                size = size - 1;
+            }
+        }
         else done = true;
     }