On Thu, Jul 23, 2020 at 03:24:13PM +0200, Jean-Marc Lasgouttes wrote: > Le 23/07/2020 à 15:13, Enrico Forestieri a écrit : > > On Thu, Jul 23, 2020 at 01:16:32PM +0200, Jean-Marc Lasgouttes wrote: > > > > > Le 23/07/2020 à 12:22, Enrico Forestieri a écrit : > > > > Here is an alternative patch. Please check whether the change in > > > > InsetMathSymbol.cpp is compatible with the corresponding change > > > > at e8ee0100. > > > > > > I think it is OK. What about the users of mathedSymbolDim in > > > InsetMathFrac? > > > Is kerning irrelevant here? > > This looks good for master and probably branch as far as I am concerned.
I am not really satisfied when navigating a formula with the cursor. The caret will be placed in the middle of a symbol instead of after it. Taking away the change to GuiFontMetrics.cpp makes navigation more pleasant but both scripts are placed far away the symbol. I propose the attached patch that leaves unchanged GuiFontMetrics::width() and makes negative the kerning for a symbol, so that the subscript is moved to the left instead of moving the superscript to the right. -- Enrico
diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp index 36bdeaa2ba..d5ef8dc1f5 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 276fab9ddc..ef2a3e94ec 100644 --- a/src/mathed/InsetMathSymbol.cpp +++ b/src/mathed/InsetMathSymbol.cpp @@ -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 kerning_ + 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; diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp index 12f8a842f6..45ca429681 100644 --- a/src/mathed/MathSupport.cpp +++ b/src/mathed/MathSupport.cpp @@ -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()); } diff --git a/src/mathed/MathSupport.h b/src/mathed/MathSupport.h index fa7b2fe0ea..9fde420ce2 100644 --- a/src/mathed/MathSupport.h +++ b/src/mathed/MathSupport.h @@ -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);
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel