/* 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_);
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_);
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;
}
-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
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());
}
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);
- Fix spacing of limits of sum-like operators in display style.
+- Fix positioning of super- and subscripts with integral signs.
+
+
* INTERNALS