mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-12 03:23:12 +00:00
Inherit outer font in text-in-math environments
Some text-in-math environments such as \text, \mbox, \fbox, and \makebox, inherit the outer text font. This commit reflects this in the on-screen representation. Fixes #12950.
This commit is contained in:
parent
de6d0bfa3f
commit
a247305b31
@ -65,7 +65,7 @@ Changer MetricsBase::changeFontSet(string const & name)
|
|||||||
string const oldname = fontname;
|
string const oldname = fontname;
|
||||||
fontname = name;
|
fontname = name;
|
||||||
if (isMathFont(name) || isMathFont(oldname))
|
if (isMathFont(name) || isMathFont(oldname))
|
||||||
font = sane_font;
|
font = isTextFont(name) ? outer_font : sane_font;
|
||||||
augmentFont(font, name);
|
augmentFont(font, name);
|
||||||
font.setSize(rc->old.font.size());
|
font.setSize(rc->old.font.size());
|
||||||
font.setStyle(rc->old.font.style());
|
font.setStyle(rc->old.font.style());
|
||||||
|
@ -46,6 +46,8 @@ public:
|
|||||||
BufferView * bv;
|
BufferView * bv;
|
||||||
/// current font
|
/// current font
|
||||||
FontInfo font;
|
FontInfo font;
|
||||||
|
/// font of the containing inset
|
||||||
|
FontInfo outer_font;
|
||||||
/// name of current font - mathed specific
|
/// name of current font - mathed specific
|
||||||
std::string fontname;
|
std::string fontname;
|
||||||
/// This is the width available in pixels
|
/// This is the width available in pixels
|
||||||
|
@ -106,6 +106,7 @@ void RowPainter::paintInset(Row::Element const & e) const
|
|||||||
|
|
||||||
pi_.base.font = e.inset->inheritFont() ? e.font.fontInfo() :
|
pi_.base.font = e.inset->inheritFont() ? e.font.fontInfo() :
|
||||||
pi_.base.bv->buffer().params().getFont().fontInfo();
|
pi_.base.bv->buffer().params().getFont().fontInfo();
|
||||||
|
pi_.base.outer_font = e.font.fontInfo();
|
||||||
pi_.ltr_pos = !e.font.isVisibleRightToLeft();
|
pi_.ltr_pos = !e.font.isVisibleRightToLeft();
|
||||||
pi_.change_ = change_.changed() ? change_ : e.change;
|
pi_.change_ = change_.changed() ? change_ : e.change;
|
||||||
pi_.do_spellcheck &= e.inset->allowSpellCheck();
|
pi_.do_spellcheck &= e.inset->allowSpellCheck();
|
||||||
|
@ -450,6 +450,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
|
|||||||
displayFont(pit, ii->pos) : bufferfont;
|
displayFont(pit, ii->pos) : bufferfont;
|
||||||
MacroContext mc(&buffer, parPos);
|
MacroContext mc(&buffer, parPos);
|
||||||
MetricsInfo mi(bv_, font.fontInfo(), w, mc);
|
MetricsInfo mi(bv_, font.fontInfo(), w, mc);
|
||||||
|
mi.base.outer_font = displayFont(pit, ii->pos).fontInfo();
|
||||||
ii->inset->metrics(mi, dim);
|
ii->inset->metrics(mi, dim);
|
||||||
if (!insetCache.has(ii->inset) || insetCache.dim(ii->inset) != dim) {
|
if (!insetCache.has(ii->inset) || insetCache.dim(ii->inset) != dim) {
|
||||||
insetCache.add(ii->inset, dim);
|
insetCache.add(ii->inset, dim);
|
||||||
|
@ -81,14 +81,14 @@ void InsetMathBox::htmlize(HtmlStream & ms) const
|
|||||||
|
|
||||||
void InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
void InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
Changer dummy = mi.base.changeFontSet("textnormal");
|
Changer dummy = mi.base.changeFontSet("text");
|
||||||
cell(0).metrics(mi, dim);
|
cell(0).metrics(mi, dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetMathBox::draw(PainterInfo & pi, int x, int y) const
|
void InsetMathBox::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
Changer dummy = pi.base.changeFontSet("textnormal");
|
Changer dummy = pi.base.changeFontSet("text");
|
||||||
cell(0).draw(pi, x, y);
|
cell(0).draw(pi, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ InsetMathFBox::InsetMathFBox(Buffer * buf)
|
|||||||
|
|
||||||
void InsetMathFBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
void InsetMathFBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
Changer dummy = mi.base.changeFontSet("textnormal");
|
Changer dummy = mi.base.changeFontSet("text");
|
||||||
cell(0).metrics(mi, dim);
|
cell(0).metrics(mi, dim);
|
||||||
// 1 pixel space, 1 frame, 1 space
|
// 1 pixel space, 1 frame, 1 space
|
||||||
dim.wid += 2 * 3;
|
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);
|
Dimension const dim = dimension(*pi.base.bv);
|
||||||
pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
|
pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
|
||||||
dim.width() - 2, dim.height() - 2, Color_foreground);
|
dim.width() - 2, dim.height() - 2, Color_foreground);
|
||||||
Changer dummy = pi.base.changeFontSet("textnormal");
|
Changer dummy = pi.base.changeFontSet("text");
|
||||||
cell(0).draw(pi, x + 3, y);
|
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
|
void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
Changer dummy = mi.base.changeFontSet("textnormal");
|
Changer dummy = mi.base.changeFontSet("text");
|
||||||
|
|
||||||
Dimension wdim;
|
Dimension wdim;
|
||||||
static docstring bracket = from_ascii("[");
|
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
|
void InsetMathMakebox::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
Changer dummy = pi.base.changeFontSet("textnormal");
|
Changer dummy = pi.base.changeFontSet("text");
|
||||||
BufferView const & bv = *pi.base.bv;
|
BufferView const & bv = *pi.base.bv;
|
||||||
int w = mathed_char_width(pi.base.font, '[');
|
int w = mathed_char_width(pi.base.font, '[');
|
||||||
|
|
||||||
|
@ -32,6 +32,10 @@ What's new
|
|||||||
- Add a few missing autocorrect combinations and allow cycling through arrows
|
- Add a few missing autocorrect combinations and allow cycling through arrows
|
||||||
(bug 12711).
|
(bug 12711).
|
||||||
|
|
||||||
|
- Reflect in the on-screen representation of math insets the fact that some
|
||||||
|
insets, such as \text, \mbox, \fbox and \makebox, inherit the text font
|
||||||
|
of the containing inset (bug 12950).
|
||||||
|
|
||||||
|
|
||||||
* DOCUMENTATION AND LOCALIZATION
|
* DOCUMENTATION AND LOCALIZATION
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user