Fix font inside footnote inset

An inset that resets its font (like Footnote) does not care at all
about enclosing font. Therefore the real starting point is the class
default font. This avoid cases where the footnote contents is forced
to \normalsize.

It turns out that the Greyedout note inset, did inherit font but was
declared as not doing it. This commmit changes the definition by
adding \normalfont\normalsize so that no inheritance happens.

Note that actually \normalfont resets everything but the font size.
This does not matter for footnote (which has its own font size) and
greyedout (which is fixed now), but may matter elsewhere. Also, I do
not know what the situation with HTML is.
This commit is contained in:
Jean-Marc Lasgouttes 2021-12-03 12:16:40 +01:00
parent 77670bc998
commit 0789f2f2ae
4 changed files with 28 additions and 9 deletions

View File

@ -180,6 +180,7 @@ InsetLayout Note:Greyedout
Requires color,lyxgreyedout
BgColor greyedoutbg
Font
Size Normal
Color greyedouttext
EndFont
LabelFont

View File

@ -560,9 +560,9 @@ docstring const lyxgreyedoutDef(bool const rtl, bool const ct, bool const lua, b
ods << " \\if@rl%\n";
ods << " \\everypar{%\n";
if (lua)
ods << " \\pardir TRT \\textdir TRT\\textcolor{note_fontcolor}\\ignorespaces%\n";
ods << " \\pardir TRT \\textdir TRT\\normalfont\\normalsize\\textcolor{note_fontcolor}\\ignorespaces%\n";
else
ods << " \\textcolor{note_fontcolor}\\beginL\\ignorespaces%\n";
ods << " \\normalfont\\normalsize\\textcolor{note_fontcolor}\\beginL\\ignorespaces%\n";
ods << " }%\n";
if (ct)
ods << " \\colorlet{lyxadded}{lyxadded!30}\\colorlet{lyxdeleted}{lyxdeleted!30}%\n";
@ -573,7 +573,7 @@ docstring const lyxgreyedoutDef(bool const rtl, bool const ct, bool const lua, b
ods << " \\else%\n";
if (ct)
ods << " \\colorlet{lyxadded}{lyxadded!30}\\colorlet{lyxdeleted}{lyxdeleted!30}%\n";
ods << " \\textcolor{note_fontcolor}\\bgroup\\ignorespaces%\n"
ods << " \\normalfont\\normalsize\\textcolor{note_fontcolor}\\bgroup\\ignorespaces%\n"
<< " \\BODY\\ignorespacesafterend\\egroup%\n"
<< " \\fi%\n"
<< "}\n";
@ -583,7 +583,7 @@ docstring const lyxgreyedoutDef(bool const rtl, bool const ct, bool const lua, b
<< "{";
if (ct)
ods << "\\colorlet{lyxadded}{lyxadded!30}\\colorlet{lyxdeleted}{lyxdeleted!30}%\n ";
ods << "\\textcolor{note_fontcolor}\\bgroup\\ignorespaces}\n"
ods << "\\normalfont\\normalsize\\textcolor{note_fontcolor}\\bgroup\\ignorespaces}\n"
<< "{\\ignorespacesafterend\\egroup}\n";
}

View File

@ -139,7 +139,26 @@ public:
mutable int inulemcmd = 0;
/** the font at the point where the inset is
*/
*
* Note from lasgouttes: I have doubts on the semantics of this
* variable. Until this is sorted out, here are some notes on the
* history of local_font.
*
* A research that excludes test and assignment [*] shows that
* this is only used to remember language, which is a different
* story (and not changed by this patch). The only exception being
* in InsetMathHull::getCtObject and InsetMathNest::latex to
* support change tracking in insets, but I am not 100% sure that
* this is required. And historically [**] local_font used to be
* local_lang; it may be good to return to this simpler variable
* later.
*
* [*] git grep local_font src|grep -v 'local_font [!=]*='
*
* [**] before afed118a, which improved support for InsetLine;
* however, since 0e7ab29f, InsetLine does not depend on the
* current font anymore.
*/
Font const * local_font = nullptr;
/** Document language lyx name

View File

@ -2539,10 +2539,9 @@ void Paragraph::latex(BufferParams const & bparams,
pos_type body_pos = beginOfBody();
unsigned int column = 0;
// If we are inside an non inheritFont() inset, the real outerfont is local_font
Font const real_outerfont = (!inInset().inheritFont()
&& runparams.local_font != nullptr)
? Font(runparams.local_font->fontInfo()) : outerfont;
// If we are inside an non inheritFont() inset, the outerfont is the default font
Font const real_outerfont =
inInset().inheritFont() ? outerfont : Font(bparams.documentClass().defaultfont());
if (body_pos > 0) {
// the optional argument is kept in curly brackets in