mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
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
This commit is contained in:
parent
dd1d973def
commit
62022d5441
@ -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>)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 <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.
|
||||
|
Loading…
Reference in New Issue
Block a user