[LyX/master] Fix on-screen display of special math fonts
Enrico Forestieri
forenr at lyx.org
Sun Sep 6 15:53:42 UTC 2020
commit 062d94c5daeede6ee75a78491d1d26be79356192
Author: Enrico Forestieri <forenr at lyx.org>
Date: Sun Sep 6 18:16:04 2020 +0200
Fix on-screen display of special math fonts
Make sure that the on-screen representation of the special math fonts
mathbb, mathds, mathfrak, mathcal, and mathscr matches the latex output.
---
src/frontends/qt/GuiFontLoader.cpp | 1 +
src/mathed/InsetMathChar.cpp | 14 ++++++++++++++
src/mathed/MathSupport.cpp | 17 ++++++++++++++---
3 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/src/frontends/qt/GuiFontLoader.cpp b/src/frontends/qt/GuiFontLoader.cpp
index c22c7f1..afbf037 100644
--- a/src/frontends/qt/GuiFontLoader.cpp
+++ b/src/frontends/qt/GuiFontLoader.cpp
@@ -215,6 +215,7 @@ QFont symbolFont(QString const & family, bool * ok)
#else
font.setFamily(family);
#endif
+ font.setStyleStrategy(QFont::NoFontMerging);
#if QT_VERSION >= 0x040800
font.setStyleName("LyX");
diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index d5ef8dc..aa1ddf8 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -118,6 +118,13 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const
Changer dummy = mi.base.font.changeShape(UP_SHAPE);
dim = theFontMetrics(mi.base.font).dimension(char_);
kerning_ = 0;
+ } else if (!isASCII(char_) && Encodings::unicodeCharInfo(char_).isUnicodeSymbol()) {
+ Changer dummy1 = mi.base.changeFontSet("mathnormal");
+ Changer dummy2 = Encodings::isMathAlpha(char_)
+ ? Changer()
+ : mi.base.font.changeShape(UP_SHAPE);
+ dim = theFontMetrics(mi.base.font).dimension(char_);
+ kerning_ = -mathed_char_kerning(mi.base.font, char_);
} else {
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
dim = fm.dimension(char_);
@@ -156,6 +163,13 @@ void InsetMathChar::draw(PainterInfo & pi, int x, int y) const
Changer dummy = pi.base.font.changeShape(UP_SHAPE);
pi.draw(x, y, char_);
return;
+ } else if (!isASCII(char_) && Encodings::unicodeCharInfo(char_).isUnicodeSymbol()) {
+ Changer dummy1 = pi.base.changeFontSet("mathnormal");
+ Changer dummy2 = Encodings::isMathAlpha(char_)
+ ? Changer()
+ : pi.base.font.changeShape(UP_SHAPE);
+ pi.draw(x, y, char_);
+ return;
}
}
// cmmi has almost no left bearing: simulate this
diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp
index ef93cb0..f5278b1 100644
--- a/src/mathed/MathSupport.cpp
+++ b/src/mathed/MathSupport.cpp
@@ -692,7 +692,13 @@ int mathedSymbolDim(MetricsBase & mb, Dimension & dim, latexkeys const * sym)
sym->extra == "mathalpha" &&
mb.fontname == "mathit";
std::string const font = italic_upcase_greek ? "cmm" : sym->inset;
- Changer dummy = mb.changeFontSet(font);
+ bool const change_font = font != "cmr" ||
+ (mb.fontname != "mathbb" &&
+ mb.fontname != "mathds" &&
+ mb.fontname != "mathfrak" &&
+ mb.fontname != "mathcal" &&
+ mb.fontname != "mathscr");
+ Changer dummy = change_font ? mb.changeFontSet(font) : Changer();
mathed_string_dim(mb.font, mathedSymbol(mb, sym), dim);
return mathed_char_kerning(mb.font, mathedSymbol(mb, sym).back());
}
@@ -710,8 +716,13 @@ void mathedSymbolDraw(PainterInfo & pi, int x, int y, latexkeys const * sym)
sym->extra == "mathalpha" &&
pi.base.fontname == "mathit";
std::string const font = italic_upcase_greek ? "cmm" : sym->inset;
-
- Changer dummy = pi.base.changeFontSet(font);
+ bool const change_font = font != "cmr" ||
+ (pi.base.fontname != "mathbb" &&
+ pi.base.fontname != "mathds" &&
+ pi.base.fontname != "mathfrak" &&
+ pi.base.fontname != "mathcal" &&
+ pi.base.fontname != "mathscr");
+ Changer dummy = change_font ? pi.base.changeFontSet(font) : Changer();
pi.draw(x, y, mathedSymbol(pi.base, sym));
}
More information about the lyx-cvs
mailing list