]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt/GuiFontMetrics.cpp
Make code a bit easier to read
[lyx.git] / src / frontends / qt / GuiFontMetrics.cpp
index b3bdac6f732712b7ddf6c898ed53f867aa52b883..0e69ffd998d09dafeb16240ead15c8c013455a80 100644 (file)
@@ -33,7 +33,7 @@
 #if QT_VERSION >= 0x050100
 #include <QtMath>
 #else
-#define qDegreesToRadians(degree) (degree * (M_PI / 180))
+#define qDegreesToRadians(degree) (degree) * (M_PI / 180)
 #endif
 
 using namespace std;
@@ -84,7 +84,8 @@ int const breakstr_cache_max_cost = 10 * 1024 * 1024;
 // Qt 5.x already has its own caching of QTextLayout objects
 // but it does not seem to work well on MacOS X.
 #if defined(Q_OS_MAC)
-//FIXME KILLQT4: check wether setting the cache to 0 hurts on macOS
+// For some reason, the built-in cache of QTextLayout does not work or
+// exist on macOS.
 // Limit qtextlayout_cache_ size to 500 elements (we do not know the
 // size of the QTextLayout objects anyway).
 int const qtextlayout_cache_max_size = 500;
@@ -116,7 +117,7 @@ inline QChar const ucs4_to_qchar(char_type const ucs4)
 
 
 GuiFontMetrics::GuiFontMetrics(QFont const & font)
-       : font_(font), metrics_(font, 0),
+       : font_(font), metrics_(font, 0), xheight_(metrics_.xHeight()),
          strwidth_cache_(strwidth_cache_max_cost),
          breakstr_cache_(breakstr_cache_max_cost),
          qtextlayout_cache_(qtextlayout_cache_max_size)
@@ -166,7 +167,7 @@ int GuiFontMetrics::em() const
 int GuiFontMetrics::xHeight() const
 {
 //     LATTEST(metrics_.xHeight() == ascent('x'));
-       return metrics_.xHeight();
+       return xheight_;
 }
 
 
@@ -256,7 +257,7 @@ int GuiFontMetrics::width(docstring const & s) const
                return *wid_p;
        PROFILE_CACHE_MISS(width);
        /* Several problems have to be taken into account:
-        * * QFontMetrics::width does not returns a wrong value with Qt5 with
+        * * QFontMetrics::width returns a wrong value with Qt5 with
         *   some arabic text, since the glyph-shaping operations are not
         *   done (documented in Qt5).
         * * QTextLayout is broken for single characters with null width