]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathChar.cpp
Allow automatic text direction in Painter::text()
[lyx.git] / src / mathed / InsetMathChar.cpp
index 03bda07cf60475c4ebaae4584ea401c613fccc12..713e1353e683ee9cff9460285b0cc7e8e36e1afa 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "support/debug.h"
 #include "support/lstrings.h"
+#include "support/lyxlib.h"
 #include "support/textutils.h"
 
 
@@ -75,11 +76,11 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const
                dim = fm.dimension(char_);
                kerning_ = fm.rbearing(char_) - dim.wid;
        }
-       int const em = mathed_char_width(mi.base.font, 'M');
+       int const em = mathed_font_em(mi.base.font);
        if (isBinaryOp(char_))
-               dim.wid += static_cast<int>(0.5*em+0.5);
+               dim.wid += support::iround(0.5 * em);
        else if (char_ == '\'')
-               dim.wid += static_cast<int>(0.1667*em+0.5);
+               dim.wid += support::iround(0.1667 * em);
 #else
        whichFont(font_, code_, mi);
        dim = theFontMetrics(font_).dimension(char_);
@@ -92,12 +93,12 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void InsetMathChar::draw(PainterInfo & pi, int x, int y) const
 {
-       //lyxerr << "drawing '" << char_ << "' font: " << pi.base.fontname << endl;
-       int const em = mathed_char_width(pi.base.font, 'M');
+       //lyxerr << "drawing '" << char_ << "' font: " << pi.base.fontname << std::endl;
+       int const em = mathed_font_em(pi.base.font);
        if (isBinaryOp(char_))
-               x += static_cast<int>(0.25*em+0.5);
+               x += support::iround(0.25 * em);
        else if (char_ == '\'')
-               x += static_cast<int>(0.0833*em+0.5);
+               x += support::iround(0.0833 * em);
 #if 1
        if (char_ == '=' && has_math_fonts) {
                FontSetChanger dummy(pi.base, "cmr");