]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/qfont_metrics.C
Some string(widget->text()) fixes. Weirdness
[lyx.git] / src / frontends / qt2 / qfont_metrics.C
index 44992d504917449832e9ed44d864de320272ebd9..3019577e8232f66d08c443883baa5c9341ceb5d4 100644 (file)
@@ -4,14 +4,13 @@
  * Licence details can be found in the file COPYING.
  *
  * \author unknown
- * \author John Levon 
+ * \author John Levon
  *
  * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
-
 #ifdef __GNUG__
 #pragma implementation "frontends/font_metrics.h"
 #endif
 #include <qfontmetrics.h>
 #include <qfont.h>
 
+
 namespace {
-       QFontMetrics const & metrics(LyXFont const & f) {
-               return fontloader.metrics(f);
-       }
+
+QFontMetrics const & metrics(LyXFont const & f)
+{
+       return fontloader.metrics(f);
 }
 
+} // namespace anon
+
 
 namespace font_metrics {
 
@@ -43,28 +46,28 @@ int maxAscent(LyXFont const & f)
 
 int maxDescent(LyXFont const & f)
 {
-       return metrics(f).descent();
+       return metrics(f).descent()+1;
+       // We add 1 as the value returned by QT is different than X
+       // See http://doc.trolltech.com/2.3/qfontmetrics.html#200b74
 }
 
 
 int ascent(char c, LyXFont const & f)
 {
        QRect r = metrics(f).boundingRect(c);
-       return abs(r.top());
+       return -r.top();
 }
 
 
 int descent(char c, LyXFont const & f)
 {
        QRect r = metrics(f).boundingRect(c);
-       return abs(r.bottom());
+       return r.bottom()+1;
 }
 
 
 int lbearing(char c, LyXFont const & f)
 {
-       lyxerr << "lb of " << c << " is " << metrics(f).leftBearing(c)
-              << std::endl;
        return metrics(f).leftBearing(c);
 }
 
@@ -85,7 +88,7 @@ int width(char const * s, size_t ls, LyXFont const & f)
                encoding = encodings.symbol_encoding();
 
        QString str;
-#if QT_VERSION >= 0x030000
+#if QT_VERSION >= 300
        str.setLength(ls);
        for (size_t i = 0; i < ls; ++i)
                str[i] = QChar(encoding->ucs(s[i]));