From de6d0bfa3fe12a40eab3268e828f4cd10e8a8e32 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Thu, 2 Nov 2023 02:05:13 +0100 Subject: [PATCH] Revert "Inherit outer font in text-in-math environments" This reverts commit f0dccbf3fbbf589e2c0a45c286a6581c1949cb28. Unfortunately, the font taken into account is the font at the current cursor position rather than the font at the corresponding math inset. --- src/MetricsInfo.cpp | 7 ++----- src/mathed/InsetMathBox.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/MetricsInfo.cpp b/src/MetricsInfo.cpp index 106c4c197d..1124ed81df 100644 --- a/src/MetricsInfo.cpp +++ b/src/MetricsInfo.cpp @@ -10,10 +10,8 @@ #include -#include "MetricsInfo.h" #include "BufferView.h" -#include "Cursor.h" - +#include "ColorSet.h" #include "LyXRC.h" #include "MetricsInfo.h" @@ -67,8 +65,7 @@ Changer MetricsBase::changeFontSet(string const & name) string const oldname = fontname; fontname = name; if (isMathFont(name) || isMathFont(oldname)) - font = isTextFont(name) ? bv->cursor().getFont().fontInfo() - : sane_font; + font = sane_font; augmentFont(font, name); font.setSize(rc->old.font.size()); font.setStyle(rc->old.font.style()); diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp index e6ed8114b5..c0df607789 100644 --- a/src/mathed/InsetMathBox.cpp +++ b/src/mathed/InsetMathBox.cpp @@ -81,14 +81,14 @@ void InsetMathBox::htmlize(HtmlStream & ms) const void InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) const { - Changer dummy = mi.base.changeFontSet("text"); + Changer dummy = mi.base.changeFontSet("textnormal"); cell(0).metrics(mi, dim); } void InsetMathBox::draw(PainterInfo & pi, int x, int y) const { - Changer dummy = pi.base.changeFontSet("text"); + Changer dummy = pi.base.changeFontSet("textnormal"); cell(0).draw(pi, x, y); } @@ -131,7 +131,7 @@ InsetMathFBox::InsetMathFBox(Buffer * buf) void InsetMathFBox::metrics(MetricsInfo & mi, Dimension & dim) const { - Changer dummy = mi.base.changeFontSet("text"); + Changer dummy = mi.base.changeFontSet("textnormal"); cell(0).metrics(mi, dim); // 1 pixel space, 1 frame, 1 space dim.wid += 2 * 3; @@ -145,7 +145,7 @@ void InsetMathFBox::draw(PainterInfo & pi, int x, int y) const Dimension const dim = dimension(*pi.base.bv); pi.pain.rectangle(x + 1, y - dim.ascent() + 1, dim.width() - 2, dim.height() - 2, Color_foreground); - Changer dummy = pi.base.changeFontSet("text"); + Changer dummy = pi.base.changeFontSet("textnormal"); cell(0).draw(pi, x + 3, y); } @@ -219,7 +219,7 @@ InsetMathMakebox::InsetMathMakebox(Buffer * buf, bool framebox) void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const { - Changer dummy = mi.base.changeFontSet("text"); + Changer dummy = mi.base.changeFontSet("textnormal"); Dimension wdim; static docstring bracket = from_ascii("["); @@ -250,7 +250,7 @@ void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const void InsetMathMakebox::draw(PainterInfo & pi, int x, int y) const { - Changer dummy = pi.base.changeFontSet("text"); + Changer dummy = pi.base.changeFontSet("textnormal"); BufferView const & bv = *pi.base.bv; int w = mathed_char_width(pi.base.font, '[');