From 78135f77517f5a1465fdba270336e1fa1b616a58 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 4 Oct 2006 10:08:51 +0000 Subject: [PATCH] enable Font cache only for MacOSX and inline width() for other platform. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15233 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiFontLoader.C | 9 ++------- src/frontends/qt4/GuiFontLoader.h | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/frontends/qt4/GuiFontLoader.C b/src/frontends/qt4/GuiFontLoader.C index 3f9fe409c9..e75bbad849 100644 --- a/src/frontends/qt4/GuiFontLoader.C +++ b/src/frontends/qt4/GuiFontLoader.C @@ -289,12 +289,9 @@ QLFontInfo::QLFontInfo(LyXFont const & f) 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 QLFontInfo::width(Uchar val) int const w = metrics.width(QChar(val)); widthcache[val] = w; return w; -#else - return metrics.width(QChar(val)); -#endif } +#endif bool GuiFontLoader::available(LyXFont const & f) diff --git a/src/frontends/qt4/GuiFontLoader.h b/src/frontends/qt4/GuiFontLoader.h index 3532aa98e7..566b7d4463 100644 --- a/src/frontends/qt4/GuiFontLoader.h +++ b/src/frontends/qt4/GuiFontLoader.h @@ -20,11 +20,10 @@ #include #include -//#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 #endif @@ -39,19 +38,24 @@ class QLFontInfo { 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 WidthCache; /// Cache of char widths WidthCache widthcache; -#endif +#endif // USE_LYX_FONTCACHE }; -- 2.39.2