mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Fix placement of limits with integral signs
Since be836909c5
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.
This commit is contained in:
parent
67c0ca678b
commit
79998fdc62
@ -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_);
|
||||
|
@ -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_);
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user