X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiFontMetrics.h;h=e2e168a9ff9464deea2cde79841c4d4c38ab354a;hb=591d47a64b8ba894be5c793472397374d0496984;hp=f3c87adc289d5c4e1336c9bb082fd5196062840b;hpb=5f4e6d9a7c829a51321c0ff612d33cb27b9b6333;p=lyx.git diff --git a/src/frontends/qt4/GuiFontMetrics.h b/src/frontends/qt4/GuiFontMetrics.h index f3c87adc28..e2e168a9ff 100644 --- a/src/frontends/qt4/GuiFontMetrics.h +++ b/src/frontends/qt4/GuiFontMetrics.h @@ -17,6 +17,7 @@ #include "support/docstring.h" #include +#include // Starting with version 3.1.0, Qt/X11 does its own caching of // character width, so it is not necessary to provide ours. @@ -27,16 +28,6 @@ namespace lyx { namespace frontend { -size_t const MaxCharType = 65536; - -struct CharMetrics -{ - int width; - int ascent; - int descent; -}; - - class GuiFontMetrics: public FontMetrics { public: @@ -82,15 +73,23 @@ private: bool smallcaps_shape_; #ifdef USE_LYX_FONTCACHE - /// fill in \c metrics_cache_ at specified value. - void fillCache(unsigned short val) const; + /// Cache of char widths /** This cache adds 20Mo of memory to the LyX executable when * loading UserGuide.lyx which contains a good number of fonts. If * this turns out to be too much, we can switch to a \c QHash based * solution. **/ - mutable CharMetrics metrics_cache_[MaxCharType]; + mutable QHash width_cache_; + + struct AscendDescend { + short int ascent; + short int descent; + }; + mutable QHash metrics_cache_; + /// fill in \c metrics_cache_ at specified value. + void fillMetricsCache(char_type) const; + #endif // USE_LYX_FONTCACHE };