]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiFontMetrics.h
* qt_helpers.h:
[lyx.git] / src / frontends / qt4 / GuiFontMetrics.h
index d310741cc33c00facdd7ce40a4d7d611b93ea3f3..e2e168a9ff9464deea2cde79841c4d4c38ab354a 100644 (file)
@@ -17,6 +17,7 @@
 #include "support/docstring.h"
 
 #include <QFontMetrics>
+#include <QHash>
 
 // Starting with version 3.1.0, Qt/X11 does its own caching of
 // character width, so it is not necessary to provide ours.
 namespace lyx {
 namespace frontend {
 
-struct CharMetrics
-{
-       int width;
-       int ascent;
-       int descent;
-};
-
-
 class GuiFontMetrics: public FontMetrics
 {
 public:
@@ -80,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_[65536];
+       mutable QHash<char_type, int> width_cache_;
+
+       struct AscendDescend {
+               short int ascent;
+               short int descent;
+       };
+       mutable QHash<char_type, AscendDescend> metrics_cache_;
+       /// fill in \c metrics_cache_ at specified value.
+       void fillMetricsCache(char_type) const;
+
 #endif // USE_LYX_FONTCACHE
 };