]> git.lyx.org Git - features.git/commitdiff
Fix placement of limits with integral signs
authorEnrico Forestieri <forenr@lyx.org>
Fri, 24 Jul 2020 17:09:17 +0000 (19:09 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Fri, 24 Jul 2020 17:09:17 +0000 (19:09 +0200)
Since be836909c52 the positioning of super- and subscripts
for symbol fonts has been broken because the metrics of the
font of the environment (rather than those of the symbol itself)
were used.

src/frontends/qt4/GuiFontMetrics.cpp
src/mathed/InsetMathChar.cpp
src/mathed/InsetMathSymbol.cpp
src/mathed/MathSupport.cpp
src/mathed/MathSupport.h
status.23x

index 67fcb2f0e4ba63bebf3d49e6b4fbcda8b7e4f205..02c50540946de18f27895049265db3c1bd3bdcc0 100644 (file)
@@ -212,16 +212,19 @@ int GuiFontMetrics::width(docstring const & s) const
        /* For some reason QMetrics::width returns a wrong value with Qt5
         * with some arabic text. OTOH, QTextLayout is broken for single
         * characters with null width (like \not in mathed). Also, as a
-        * safety measure, always use QMetrics::width with our math fonts.
+        * safety measure, always use QMetrics::boundingRect().width()
+        * with our math fonts.
        */
        int w = 0;
        if (s.length() == 1
 #if QT_VERSION >= 0x040800
            || font_.styleName() == "LyX"
 #endif
-           )
-               w = metrics_.width(toqstr(s));
-       else {
+           ) {
+               // keep value 0 for math chars with null width
+               if (metrics_.width(toqstr(s)) != 0)
+                       w = metrics_.boundingRect(toqstr(s)).width();
+       } else {
                QTextLayout tl;
                tl.setText(toqstr(s));
                tl.setFont(font_);
index 1137c95e75a8b0e709f91169b52465978ccc837d..3a9d18c5c20f39ec14bcad78facd72f44720d3d7 100644 (file)
@@ -113,9 +113,7 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const
        if (isMathFont(f) && subst_) {
                // If the char has a substitute, draw the replacement symbol
                // instead, but only in math mode.
-               mathedSymbolDim(mi.base, dim, subst_);
-               kerning_ = mathed_char_kerning(mi.base.font, *subst_->draw.rbegin());
-               return;
+               kerning_ = mathedSymbolDim(mi.base, dim, subst_);
        } else if (!slanted(char_) && f == "mathnormal") {
                Changer dummy = mi.base.font.changeShape(UP_SHAPE);
                dim = theFontMetrics(mi.base.font).dimension(char_);
index 92d2573560a4ad808141d0d999f7263ac77012ea..106780e5780eaad8056281906c9d999165d76668 100644 (file)
@@ -60,10 +60,8 @@ docstring InsetMathSymbol::name() const
 
 void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       // set dim
-       mathedSymbolDim(mi.base, dim, sym_);
-       // set kerning_
-       kerning_ = mathed_char_kerning(mi.base.font, *sym_->draw.rbegin());
+       // set dim and negative kerning_ to move a subscript leftward
+       kerning_ = -mathedSymbolDim(mi.base, dim, sym_);
        // correct height for broken cmex and wasy font
        if (sym_->inset == "cmex" || sym_->inset == "wasy") {
                h_ = 4 * dim.des / 5;
index b9ea145c678de5b80c51c3cff8f1f7306fd5b7d5..26d508f12c46f596c6afc7b79114f7a04c25ee4f 100644 (file)
@@ -673,9 +673,9 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
 }
 
 
-void mathedSymbolDim(MetricsBase & mb, Dimension & dim, latexkeys const * sym)
+int mathedSymbolDim(MetricsBase & mb, Dimension & dim, latexkeys const * sym)
 {
-       LASSERT((bool)sym, return);
+       LASSERT((bool)sym, return 0);
        //lyxerr << "metrics: symbol: '" << sym->name
        //      << "' in font: '" << sym->inset
        //      << "' drawn as: '" << sym->draw
@@ -687,6 +687,7 @@ void mathedSymbolDim(MetricsBase & mb, Dimension & dim, latexkeys const * sym)
        std::string const font = italic_upcase_greek ? "cmm" : sym->inset;
        Changer dummy = mb.changeFontSet(font);
        mathed_string_dim(mb.font, sym->draw, dim);
+       return mathed_char_kerning(mb.font, sym->draw.back());
 }
 
 
index d9301453dde5bb9c2cb5330c6430f9089e96c213..7c40baa0b48533a02b3c51bc4e56023c3023bfa4 100644 (file)
@@ -55,7 +55,7 @@ void mathed_string_dim(FontInfo const & font,
 
 int mathed_string_width(FontInfo const &, docstring const & s);
 
-void mathedSymbolDim(MetricsBase & mb, Dimension & dim, latexkeys const * sym);
+int mathedSymbolDim(MetricsBase & mb, Dimension & dim, latexkeys const * sym);
 
 void mathedSymbolDraw(PainterInfo & pi, int x, int y, latexkeys const * sym);
 
index 1307003d96064887f887aa26c25316904ee2cb32..080634f74e865b89c5baf09c6685fc6ca1895717 100644 (file)
@@ -78,6 +78,9 @@ What's new
 
 - Fix spacing of limits of sum-like operators in display style.
 
+- Fix positioning of super- and subscripts with integral signs.
+
+
 * INTERNALS