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
9e977932c5
commit
0b3e69167c
@ -226,8 +226,17 @@ int GuiFontMetrics::width(docstring const & s) const
|
||||
* for text strings, it does not give a good result with some
|
||||
* characters like the \int (gyph 4) of esint.
|
||||
|
||||
* Also, as a safety measure, always use QFontMetrics::width with
|
||||
* our math fonts.
|
||||
* The metrics of some of our math fonts (eg. esint) are such that
|
||||
* QTextLine::horizontalAdvance leads, more or less, in the middle
|
||||
* of a symbol. This is the horizontal position where a subscript
|
||||
* should be drawn, so that the superscript has to be moved rightward.
|
||||
* This is done when the kerning() method of the math insets returns
|
||||
* a positive value. The problem with this choice is that navigating
|
||||
* a formula becomes weird. For example, a selection extends only over
|
||||
* about half of the symbol. In order to avoid this, with our math
|
||||
* fonts we use QTextLine::naturalTextWidth, so that a superscript can
|
||||
* be drawn right after the symbol, and move the subscript leftward by
|
||||
* recording a negative value for the kerning.
|
||||
*/
|
||||
int w = 0;
|
||||
// is the string a single character from a math 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_);
|
||||
|
@ -68,14 +68,11 @@ Limits InsetMathSymbol::defaultLimits() const
|
||||
|
||||
void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
mathedSymbolDim(mi.base, dim, sym_);
|
||||
// set dim
|
||||
// FIXME: this should depend on BufferView
|
||||
// set negative kerning_ so that a subscript is moved leftward
|
||||
kerning_ = -mathedSymbolDim(mi.base, dim, sym_);
|
||||
if (sym_->draw != sym_->name) {
|
||||
// set dim
|
||||
// FIXME: this should depend on BufferView
|
||||
// set kerning_
|
||||
kerning_ = mathed_char_kerning(mi.base.font,
|
||||
mathedSymbol(mi.base, sym_).back());
|
||||
|
||||
// align character vertically
|
||||
// FIXME: this should depend on BufferView
|
||||
h_ = 0;
|
||||
|
@ -680,9 +680,9 @@ docstring const & mathedSymbol(MetricsBase & mb, latexkeys const * sym)
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
@ -694,6 +694,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, mathedSymbol(mb, sym), dim);
|
||||
return mathed_char_kerning(mb.font, mathedSymbol(mb, sym).back());
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ int mathed_string_width(FontInfo const &, docstring const & s);
|
||||
|
||||
docstring const & mathedSymbol(MetricsBase & mb, latexkeys const * sym);
|
||||
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user