]> git.lyx.org Git - lyx.git/commitdiff
Factor code for math axis height
authorGuillaume Munch <gm@lyx.org>
Mon, 19 Dec 2016 23:15:59 +0000 (00:15 +0100)
committerGuillaume Munch <gm@lyx.org>
Mon, 19 Dec 2016 23:15:59 +0000 (00:15 +0100)
src/mathed/InsetMathFrac.cpp
src/mathed/MathSupport.cpp
src/mathed/MathSupport.h

index ad999a221d76b3ccf57072dab40e87f141bfe55b..ada6476c50cd9edce15c256756e2416222699009 100644 (file)
@@ -154,14 +154,6 @@ MathClass InsetMathFrac::mathClass() const
 
 namespace {
 
-// align frac to minus character
-int dy_for_frac(MetricsBase & mb)
-{
-       Changer dummy = mb.changeFontSet("mathnormal");
-       return theFontMetrics(mb.font).ascent('-') - 1;
-}
-
-
 // align the top of M in the cell with the top of M in the surrounding font
 int dy_for_nicefrac(MetricsBase & mb)
 {
@@ -249,7 +241,7 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const
        case TFRAC:
        case OVER:
        case ATOP: {
-               int const dy = dy_for_frac(mi.base);
+               int const dy = axis_height(mi.base);
                Changer dummy =
                        // \tfrac is always in text size
                        (kind_ == TFRAC) ? mi.base.font.changeStyle(LM_ST_SCRIPT) :
@@ -332,7 +324,7 @@ void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const
        case TFRAC:
        case OVER:
        case ATOP: {
-               int const dy = dy_for_frac(pi.base);
+               int const dy = axis_height(pi.base);
                Changer dummy =
                        // \tfrac is always in text size
                        (kind_ == TFRAC) ? pi.base.font.changeStyle(LM_ST_SCRIPT) :
@@ -658,7 +650,7 @@ void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        Changer dummy2 = mi.base.changeEnsureMath();
        Dimension dim0, dim1;
-       int const dy = dy_for_frac(mi.base);
+       int const dy = axis_height(mi.base);
        Changer dummy =
                (kind_ == DBINOM) ? mi.base.font.changeStyle(LM_ST_DISPLAY) :
                (kind_ == TBINOM) ? mi.base.font.changeStyle(LM_ST_SCRIPT) :
@@ -678,7 +670,7 @@ void InsetMathBinom::draw(PainterInfo & pi, int x, int y) const
        Dimension const dim = dimension(*pi.base.bv);
        Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
        Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
-       int const dy = dy_for_frac(pi.base);
+       int const dy = axis_height(pi.base);
        // define the binom brackets
        docstring const bra = kind_ == BRACE ? from_ascii("{") :
                kind_ == BRACK ? from_ascii("[") : from_ascii("(");
index 222807bba4a40b303d92492a913af6f68932e5df..5df8a0673e76bde13a416722de542f0832fd1fc5 100644 (file)
@@ -985,4 +985,11 @@ docstring asString(MathAtom const & at)
 }
 
 
+int axis_height(MetricsBase & mb)
+{
+       Changer dummy = mb.changeFontSet("mathnormal");
+       return theFontMetrics(mb.font).ascent('-') - 1;
+}
+
+
 } // namespace lyx
index 87f824dc1685cc4f96a43fc38274dc072170b67c..2b3e48f68f7233fa278384248a9a9f8c7494c4dd 100644 (file)
@@ -81,6 +81,9 @@ docstring asString(MathAtom const &);
 // converts string to single cell
 void asArray(docstring const &, MathData &, Parse::flags f = Parse::NORMAL);
 
+// simulate axis height (font dimension sigma 22)
+int axis_height(MetricsBase & mb);
+
 } // namespace lyx
 
 #endif