Le 03/12/2021 à 17:00, Scott Kostyshak a écrit :
On Fri, Dec 03, 2021 at 12:46:13PM +0100, Jean-Marc Lasgouttes wrote:
Le 31/10/2021 � 18:11, Scott Kostyshak a �crit�:
See the attached file. On master, \normalsize is included inside the footnote, 
which is different from 2.3.x.

Here is my take on how to properly fix this issue. I do not know however
what it does in other situations. Scott, do you have magic scripts and tests
to see the effect of this?

No magic scripts. All I do is manually compile the 2.3.0 user documents
with 2.3.0 (or 2.3.x) and with master and then run 'diffpdf' on the
results. I'm not sure it makes sense to test that the LaTeX is
equivalent since often there are differences in LyX's LaTeX output that
are expected that do not cause a difference in the PDF output. We could
imagine some automated tests with e.g. 'comparepdf' (a commandline tool)
that I think could check whether the PDF output are the same. We'd have
to disable the date showing up.

OK, I have done the main manuals, and found in UserGuide a place where a greyedout note was inserted in bold context. This shows that a \normalfont was missing in the lyxgreyedout definition, and the updated patch adds that.

What else could I try to be convinced that it works? Do we have font torture tests?

JMarc

From d64803774ca24546c33e55dd9b22fefbb51ad4d1 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Fri, 3 Dec 2021 12:16:40 +0100
Subject: [PATCH] Tentative patch: 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 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), but
may matter elsewhere, for example Greyedout. Also, I do not know what
the situation with HTML is.
---
 src/LaTeXFeatures.cpp |  8 ++++----
 src/OutputParams.h    | 21 ++++++++++++++++++++-
 src/Paragraph.cpp     |  7 +++----
 3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 0344202c91..abe1ca1d79 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -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\\textcolor{note_fontcolor}\\ignorespaces%\n";
 		else
-			ods << "      \\textcolor{note_fontcolor}\\beginL\\ignorespaces%\n";
+			ods << "      \\normalfont\\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\\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\\textcolor{note_fontcolor}\\bgroup\\ignorespaces}\n"
 		    << "{\\ignorespacesafterend\\egroup}\n";
 	}
 
diff --git a/src/OutputParams.h b/src/OutputParams.h
index 7ca5c1ff62..a909ddd925 100644
--- a/src/OutputParams.h
+++ b/src/OutputParams.h
@@ -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
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 7fb46aee7d..f78925fafb 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -2533,10 +2533,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
-- 
2.32.0

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to