[LyX/master] Assure \par is output when needed with fontswitch

Juergen Spitzmueller spitz at lyx.org
Wed Dec 2 13:02:30 UTC 2020


commit 098c16f153df4cd9960d2a58a6ef9146d99861ad
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Wed Dec 2 14:32:05 2020 +0100

    Assure \par is output when needed with fontswitch
---
 src/Paragraph.cpp |   60 ++++++++++++++++++++++++++--------------------------
 1 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 5d1003d..5930cb8 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -2903,6 +2903,31 @@ void Paragraph::latex(BufferParams const & bparams,
 		alien_script.clear();
 	}
 
+	Font const font = empty()
+		? getLayoutFont(bparams, real_outerfont)
+		: getFont(bparams, size() - 1, real_outerfont);
+
+	InsetText const * textinset = inInset().asInsetText();
+
+	bool const maintext = textinset
+		? textinset->text().isMainText()
+		: false;
+
+	size_t const numpars = textinset
+		? textinset->text().paragraphs().size()
+		: 0;
+
+	bool needPar = false;
+
+	if (style.resfont.size() != font.fontInfo().size()
+	    && (!runparams.isLastPar || maintext
+		|| (numpars > 1 && d->ownerCode() != CELL_CODE
+		    && (inInset().getLayout().isDisplay()
+			|| parInline)))
+	    && !style.isCommand()) {
+		needPar = true;
+	}
+
 	// If we have an open font definition, we have to close it
 	if (open_font) {
 		// Make sure that \\par is done with the font of the last
@@ -2914,31 +2939,6 @@ void Paragraph::latex(BufferParams const & bparams,
 		// We must not change the font for the last paragraph
 		// of non-multipar insets, tabular cells or commands,
 		// since this produces unwanted whitespace.
-
-		Font const font = empty()
-			? getLayoutFont(bparams, real_outerfont)
-			: getFont(bparams, size() - 1, real_outerfont);
-
-		InsetText const * textinset = inInset().asInsetText();
-
-		bool const maintext = textinset
-			? textinset->text().isMainText()
-			: false;
-
-		size_t const numpars = textinset
-			? textinset->text().paragraphs().size()
-			: 0;
-
-		bool needPar = false;
-
-		if (style.resfont.size() != font.fontInfo().size()
-		    && (!runparams.isLastPar || maintext
-			|| (numpars > 1 && d->ownerCode() != CELL_CODE
-			    && (inInset().getLayout().isDisplay()
-				|| parInline)))
-		    && !style.isCommand()) {
-			needPar = true;
-		}
 #ifdef FIXED_LANGUAGE_END_DETECTION
 		if (next_) {
 			running_font.latexWriteEndChanges(os, bparams,
@@ -2956,11 +2956,11 @@ void Paragraph::latex(BufferParams const & bparams,
 		running_font.latexWriteEndChanges(os, bparams, runparams,
 				basefont, basefont, needPar);
 #endif
-		if (needPar) {
-			// The \par could not be inserted at the same nesting
-			// level of the font size change, so do it now.
-			os << "{\\" << font.latexSize() << "\\par}";
-		}
+	}
+	if (needPar) {
+		// The \par could not be inserted at the same nesting
+		// level of the font size change, so do it now.
+		os << "{\\" << font.latexSize() << "\\par}";
 	}
 
 	column += Changes::latexMarkChange(os, bparams, runningChange,


More information about the lyx-cvs mailing list