Jean-Marc Lasgouttes wrote:
"Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes:
Andre> Remove width cache for Qt 4 frontend.
Instead of doing this, I propose for now that you disable the font
cache for linux and keep it for MAC. Windows will need some testing
too.
I've tested it and it's OK with Andre inline solution. I've committed
this instead:
URL: http://www.lyx.org/trac/changeset/15233
Log:
enable Font cache only for MacOSX and inline width() for other platform.
Modified:
lyx-devel/trunk/src/frontends/qt4/GuiFontLoader.C
lyx-devel/trunk/src/frontends/qt4/GuiFontLoader.h
Modified: lyx-devel/trunk/src/frontends/qt4/GuiFontLoader.C
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiFontLoader.C?rev=15233
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiFontLoader.C (original)
+++ lyx-devel/trunk/src/frontends/qt4/GuiFontLoader.C Wed Oct 4
12:08:51 2006
@@ -289,12 +289,9 @@
metrics = QFontMetrics(font);
}
-
+#ifdef USE_LYX_FONTCACHE
int QLFontInfo::width(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)
QLFontInfo::WidthCache::const_iterator cit = widthcache.find(val);
if (cit != widthcache.end())
return cit->second;
@@ -302,10 +299,8 @@
int const w = metrics.width(QChar(val));
widthcache[val] = w;
return w;
-#else
- return metrics.width(QChar(val));
+}
#endif
-}
bool GuiFontLoader::available(LyXFont const & f)
Modified: lyx-devel/trunk/src/frontends/qt4/GuiFontLoader.h
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiFontLoader.h?rev=15233
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiFontLoader.h (original)
+++ lyx-devel/trunk/src/frontends/qt4/GuiFontLoader.h Wed Oct 4
12:08:51 2006
@@ -20,11 +20,10 @@
#include <QFont>
#include <QFontMetrics>
-//#if QT_VERSION < 0x030100
+// 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(Q_WS_MACX)
#define USE_LYX_FONTCACHE
-//#endif
-
-#if defined(USE_LYX_FONTCACHE)
#include <map>
#endif
@@ -39,19 +38,24 @@
public:
QLFontInfo(LyXFont const & f);
- /// Return pixel width for the given unicode char
- int width(Uchar val);
-
/// The font instance
QFont font;
/// Metrics on the font
QFontMetrics metrics;
-#if defined(USE_LYX_FONTCACHE)
+#ifndef USE_LYX_FONTCACHE
+ /// Return pixel width for the given unicode char
+ int width(Uchar val) { return metrics.width(QChar(val)); }
+
+#else
+ /// Return pixel width for the given unicode char
+ int width(Uchar val);
+
+private:
typedef std::map<Uchar, int> WidthCache;
/// Cache of char widths
WidthCache widthcache;
-#endif
+#endif // USE_LYX_FONTCACHE
};