diff --git a/src/frontends/qt4/GuiFontMetrics.cpp b/src/frontends/qt4/GuiFontMetrics.cpp index 67fcb2f0e4..02c5054094 100644 --- a/src/frontends/qt4/GuiFontMetrics.cpp +++ b/src/frontends/qt4/GuiFontMetrics.cpp @@ -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_); diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp index 1137c95e75..3a9d18c5c2 100644 --- a/src/mathed/InsetMathChar.cpp +++ b/src/mathed/InsetMathChar.cpp @@ -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_); diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp index 92d2573560..106780e578 100644 --- a/src/mathed/InsetMathSymbol.cpp +++ b/src/mathed/InsetMathSymbol.cpp @@ -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; diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp index b9ea145c67..26d508f12c 100644 --- a/src/mathed/MathSupport.cpp +++ b/src/mathed/MathSupport.cpp @@ -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()); } diff --git a/src/mathed/MathSupport.h b/src/mathed/MathSupport.h index d9301453dd..7c40baa0b4 100644 --- a/src/mathed/MathSupport.h +++ b/src/mathed/MathSupport.h @@ -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); diff --git a/status.23x b/status.23x index 1307003d96..080634f74e 100644 --- a/status.23x +++ b/status.23x @@ -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