From 62022d5441575f3d226f57f10d7d4dbcb8de3935 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 10 Jun 2005 14:53:42 +0000 Subject: [PATCH] do not cache font width with recent Qt versions git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10043 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 6 ++++++ src/frontends/qt2/qfont_loader.C | 6 ++++++ src/frontends/qt2/qfont_loader.h | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 90b51860a3..f283d249a4 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,9 @@ +2005-06-09 Jean-Marc Lasgouttes + + * qfont_loader.h: + * qfont_loader.C (charwidth): do no do font width caching with + Qt >= 3.1.0. + 2005-06-06 Lars Gullik Bjonnes (Committed Martin Vermeer ) diff --git a/src/frontends/qt2/qfont_loader.C b/src/frontends/qt2/qfont_loader.C index 8353046132..affc4fe047 100644 --- a/src/frontends/qt2/qfont_loader.C +++ b/src/frontends/qt2/qfont_loader.C @@ -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 } diff --git a/src/frontends/qt2/qfont_loader.h b/src/frontends/qt2/qfont_loader.h index 6a182090e1..771f77444e 100644 --- a/src/frontends/qt2/qfont_loader.h +++ b/src/frontends/qt2/qfont_loader.h @@ -12,8 +12,13 @@ #ifndef QFONTLOADER_H #define QFONTLOADER_H +#if QT_VERSION < 0x030100 +#define USE_LYX_FONTCACHE +#endif +#if defined(USE_LYX_FONTCACHE) #include +#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 WidthCache; /// cache of char widths WidthCache widthcache; +#endif }; /// get font info (font + metrics) for the given LyX font. Does not fail.