]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/font_metrics.h
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / font_metrics.h
index 4d4a79b83a6d9104c191755cccea50d6c30ae568..9c6becdab9085e3a6b76aa861c404cf7e370119b 100644 (file)
@@ -13,9 +13,7 @@
 #ifndef FONT_METRICS_H
 #define FONT_METRICS_H
 
-#include "support/types.h"
-
-#include <string>
+#include "support/docstring.h"
 
 
 class LyXFont;
@@ -57,7 +55,8 @@ namespace font_metrics {
        /// return the descent of the char in the font
        int descent(lyx::char_type c, LyXFont const & f);
        /// return the descent of the char in the font
-       inline int height(lyx::char_type c, LyXFont const & f) {
+       inline int height(lyx::char_type c, LyXFont const & f)
+       {
                return ascent(c, f) + descent(c, f);
        }
        /// return the left bearing of the char in the font
@@ -69,22 +68,25 @@ namespace font_metrics {
                return (rbearing(c, f) - lbearing(c, f)) / 2;
        }
        /// return the width of the string in the font
-       int width(char const * s, size_t n, LyXFont const & f);
+       int width(lyx::char_type const * s, size_t n, LyXFont const & f);
        /// return the width of the char in the font
-       inline int width(lyx::char_type c, LyXFont const & f) {
-               return width(&c, 1, f);
+       inline int width(lyx::char_type c, LyXFont const & f)
+       {
+               lyx::char_type tmp[2] = { c, L'\0'};
+               return width(tmp, 1, f);
        }
        /// return the width of the string in the font
-       inline int width(std::string const & s, LyXFont const & f) {
-               return s.empty() ? 0 : width(s.data(), s.length(), f);
+       inline int width(lyx::docstring const & s, LyXFont const & f)
+       {
+           return s.empty() ? 0 : width(s.data(), s.length(), f);
        }
        /// FIXME ??
-       int signedWidth(std::string const & s, LyXFont const & f);
+       int signedWidth(lyx::docstring const & s, LyXFont const & f);
        /**
         * fill in width,ascent,descent with the values for the
         * given string in the font.
         */
-       void rectText(std::string const & str, LyXFont const & font,
+       void rectText(lyx::docstring const & str, LyXFont const & font,
                int & width,
                int & ascent,
                int & descent);
@@ -92,7 +94,7 @@ namespace font_metrics {
         * fill in width,ascent,descent with the values for the
         * given string in the font for a button.
         */
-       void buttonText(std::string const & str, LyXFont const & font,
+       void buttonText(lyx::docstring const & str, LyXFont const & font,
                int & width,
                int & ascent,
                int & descent);