+2005-06-09 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * qfont_loader.h:
+ * qfont_loader.C (charwidth): do no do font width caching with
+ Qt >= 3.1.0.
+
2005-06-06 Lars Gullik Bjonnes <larsbj@gullik.net>
(Committed Martin Vermeer <martin.vermeer@hut.fi>)
int qfont_loader::charwidth(LyXFont const & f, Uchar val)
{
+// Starting with version 3.1.0, Qt/X11 does its own caching of
+// character width, so it is not necessary to provide ours.
+#if defined (USE_LYX_FONTCACHE)
font_info * fi = getfontinfo(f);
font_info::WidthCache::const_iterator cit = fi->widthcache.find(val);
int const w = fi->metrics.width(QChar(val));
fi->widthcache[val] = w;
return w;
+#else
+ return getfontinfo(f)->metrics.width(QChar(val));
+#endif
}
#ifndef QFONTLOADER_H
#define QFONTLOADER_H
+#if QT_VERSION < 0x030100
+#define USE_LYX_FONTCACHE
+#endif
+#if defined(USE_LYX_FONTCACHE)
#include <map>
+#endif
#include "encoding.h"
#include "lyxfont.h"
/// metrics on the font
QFontMetrics metrics;
+#if defined(USE_LYX_FONTCACHE)
typedef std::map<Uchar, int> WidthCache;
/// cache of char widths
WidthCache widthcache;
+#endif
};
/// get font info (font + metrics) for the given LyX font. Does not fail.