]> git.lyx.org Git - lyx.git/commitdiff
do not cache font width with recent Qt versions
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 10 Jun 2005 14:53:42 +0000 (14:53 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 10 Jun 2005 14:53:42 +0000 (14:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10043 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/qfont_loader.C
src/frontends/qt2/qfont_loader.h

index 90b51860a3c3bbe523ffdf380cd12220e9a133b9..f283d249a4860e735a219a40a8b2067823c0e3b1 100644 (file)
@@ -1,3 +1,9 @@
+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>)
 
index 8353046132bd32ebebb38a77f4cf85c45f808bd0..affc4fe047d42e081266d654951084648139f174 100644 (file)
@@ -375,6 +375,9 @@ qfont_loader::font_info * qfont_loader::getfontinfo(LyXFont const & f)
 
 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);
@@ -384,6 +387,9 @@ int qfont_loader::charwidth(LyXFont const & f, Uchar val)
        int const w = fi->metrics.width(QChar(val));
        fi->widthcache[val] = w;
        return w;
+#else
+       return getfontinfo(f)->metrics.width(QChar(val));
+#endif
 }
 
 
index 6a182090e1e669b9c0a3e3495b9763603d084652..771f77444e721ee8f48664a67efa799027dafa02 100644 (file)
 #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"
@@ -65,9 +70,11 @@ private:
                /// 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.