#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;
// 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;
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)
int GuiFontMetrics::xHeight() const
{
// LATTEST(metrics_.xHeight() == ascent('x'));
- return metrics_.xHeight();
+ return xheight_;
}
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