]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/font_metrics.h
fix math fonts with LyX/Mac
[lyx.git] / src / frontends / font_metrics.h
index 481bb2d160da0c44024add77757a61cab4cf09e5..6a83b25d03c23940d56b0049ac76a2e3c25a4b52 100644 (file)
@@ -7,13 +7,14 @@
  * \author unknown
  * \author John Levon
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #ifndef FONT_METRICS_H
 #define FONT_METRICS_H
 
-#include "LString.h"
+#include <string>
+
 
 class LyXFont;
 
@@ -45,14 +46,26 @@ namespace font_metrics {
        int maxAscent(LyXFont const & f);
        /// return the maximum descent of the font
        int maxDescent(LyXFont const & f);
+       /// return the maximum descent of the font
+       inline int maxHeight(LyXFont const & f) {
+               return maxAscent(f) + maxDescent(f);
+       }
        /// return the ascent of the char in the font
        int ascent(char c, LyXFont const & f);
        /// return the descent of the char in the font
        int descent(char c, LyXFont const & f);
+       /// return the descent of the char in the font
+       inline int height(char c, LyXFont const & f) {
+               return ascent(c, f) + descent(c, f);
+       }
        /// return the left bearing of the char in the font
        int lbearing(char c, LyXFont const & f);
        /// return the right bearing of the char in the font
        int rbearing(char c, LyXFont const & f);
+       /// return the inner width of the char in the font
+       inline int center(char c, LyXFont const & f) {
+               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);
        /// return the width of the char in the font
@@ -60,17 +73,16 @@ namespace font_metrics {
                return width(&c, 1, f);
        }
        /// return the width of the string in the font
-       inline int width(string const & s, LyXFont const & f) {
-               if (s.empty()) return 0;
-               return width(s.data(), s.length(), f);
+       inline int width(std::string const & s, LyXFont const & f) {
+               return s.empty() ? 0 : width(s.data(), s.length(), f);
        }
        /// FIXME ??
-       int signedWidth(string const & s, LyXFont const & f);
+       int signedWidth(std::string const & s, LyXFont const & f);
        /**
         * fill in width,ascent,descent with the values for the
         * given string in the font.
         */
-       void rectText(string const & str, LyXFont const & font,
+       void rectText(std::string const & str, LyXFont const & font,
                int & width,
                int & ascent,
                int & descent);
@@ -78,7 +90,7 @@ namespace font_metrics {
         * fill in width,ascent,descent with the values for the
         * given string in the font for a button.
         */
-       void buttonText(string const & str, LyXFont const & font,
+       void buttonText(std::string const & str, LyXFont const & font,
                int & width,
                int & ascent,
                int & descent);