]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/FontMetrics.h
tex2lyx: support for \item with opt arg in itemize environment
[lyx.git] / src / frontends / FontMetrics.h
index cdad1946da1a67ad72db898a3e1afae4a4cc293c..56e47eaeabbbc5473958332c6d3f841306cb67a9 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef FONT_METRICS_H
 #define FONT_METRICS_H
 
-#include "support/docstring.h"
+#include "support/strfwd.h"
 
 /**
  * A class holding helper functions for determining
@@ -77,6 +77,19 @@ public:
        virtual int width(docstring const & s) const = 0;
        /// FIXME ??
        virtual int signedWidth(docstring const & s) const = 0;
+       /**
+        * return the x offset of a position in the string. The
+        * direction of the string is forced, and the returned value
+        * is from the left edge of the word, not from the start of the string.
+        */
+       virtual int pos2x(docstring const & s, int pos, bool rtl) const = 0;
+       /**
+        * return the position in the string for a given x offset. The
+        * direction of the string is forced, and the returned value
+        * is from the left edge of the word, not from the start of the string.
+        * the offset x is updated to match the closest position in the string.
+        */
+       virtual int x2pos(docstring const & s, int & x, bool rtl) const = 0;
        /// return char dimension for the font.
        virtual Dimension const dimension(char_type c) const = 0;
        /**
@@ -97,15 +110,10 @@ public:
                int & descent) const = 0;
 
        /// return the maximum descent of the font
-       inline int maxHeight() const {
-               return maxAscent() + maxDescent();
-       }
+       inline int maxHeight() const { return maxAscent() + maxDescent(); }
 
        /// return the descent of the char in the font
-       inline int height(char_type c) const
-       {
-               return ascent(c) + descent(c);
-       }
+       inline int height(char_type c) const { return ascent(c) + descent(c); }
 
        /// return the inner width of the char in the font
        inline int center(char_type c) const {
@@ -116,10 +124,12 @@ public:
 
 } // namespace frontend
 
-class LyXFont;
+class Font;
+class FontInfo;
 
-/// Implementation is in Application.C
-frontend::FontMetrics const & theFontMetrics(LyXFont const & f);
+/// Implementation is in Application.cpp
+frontend::FontMetrics const & theFontMetrics(Font const & f);
+frontend::FontMetrics const & theFontMetrics(FontInfo const & fi);
 
 } // namespace lyx