X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiFontMetrics.h;h=3f50dfe5d29902d0516e2b27c3ca2ec32fa4d4e4;hb=28be7d552f62cc02fa86d7f79201d089bfb2d7b5;hp=75507b0c99cf1abdcc68b2cca28e806ac7e3cfa8;hpb=cf6128caf664378f15d9c93b6d35621e19f4eecb;p=lyx.git diff --git a/src/frontends/qt4/GuiFontMetrics.h b/src/frontends/qt4/GuiFontMetrics.h index 75507b0c99..3f50dfe5d2 100644 --- a/src/frontends/qt4/GuiFontMetrics.h +++ b/src/frontends/qt4/GuiFontMetrics.h @@ -14,13 +14,15 @@ #include "frontends/FontMetrics.h" +#include "support/Cache.h" #include "support/docstring.h" -#include - #include #include #include +#include + +#include namespace lyx { namespace frontend { @@ -56,13 +58,25 @@ public: int & ascent, int & descent) const; virtual void buttonText(docstring const & str, + const int offset, int & width, int & ascent, int & descent) const; + + int countExpanders(docstring const & str) const; /// int width(QString const & str) const; + /// Return a pointer to a cached QTextLayout object + std::shared_ptr + getTextLayout(docstring const & s, bool const rtl, + double const wordspacing) const; + private: + + std::pair breakAt_helper(docstring const & s, int const x, + bool const rtl, bool const force) const; + /// The font QFont font_; @@ -71,10 +85,12 @@ private: /// Cache of char widths mutable QHash width_cache_; - /// Cache of string widths - /// FIXME Try to use a QHash (this requires to define qHash(docstring)) - mutable std::map strwidth_cache_; + mutable Cache strwidth_cache_; + /// Cache for breakAt + mutable Cache> breakat_cache_; + /// Cache for QTextLayout + mutable Cache> qtextlayout_cache_; struct AscendDescend { int ascent; @@ -87,6 +103,7 @@ private: /// Cache of char right bearings mutable QHash rbearing_cache_; + }; } // namespace frontend