Am Montag, dem 01.11.2021 um 10:29 +0100 schrieb Jürgen Spitzmüller:
> On another look I tend to think that, rather than overwriting metrics
> and draw in individual insets, we would need a method similar to
> inheritFont() which only applies to screen font (I thought that
> resetsFonEdit() is that, but it isn't).

Something like the attached. I figure, in the long run we also need a
layout tag.

Jürgen

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 400b7b66e8..c35526bd77 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -100,7 +100,7 @@ void RowPainter::paintInset(Row::Element const & e) const
 	bool const pi_do_spellcheck = pi_.do_spellcheck;
 	Change const pi_change = pi_.change;
 
-	pi_.base.font = e.inset->inheritFont() ? e.font.fontInfo() :
+	pi_.base.font = e.inset->inheritScreenFont() ? e.font.fontInfo() :
 		pi_.base.bv->buffer().params().getFont().fontInfo();
 	pi_.ltr_pos = !e.font.isVisibleRightToLeft();
 	pi_.change = pi_.change.changed() ? pi_.change : e.change;
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index a2a3e4b427..e8a13dc3f8 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -505,7 +505,7 @@ bool TextMetrics::redoParagraph(pit_type const pit, bool const align_rows)
 		Dimension dim;
 		int const w = max_width_ - leftMargin(pit, e.pos)
 			- right_margin - eop;
-		Font const & font = e.inset->inheritFont() ?
+		Font const & font = e.inset->inheritScreenFont() ?
 			displayFont(pit, e.pos) : bufferfont;
 		MacroContext mc(&buffer, parPos);
 		MetricsInfo mi(bv_, font.fontInfo(), w, mc, e.pos == 0, tight_);
diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index af24423e4e..d62cc5d556 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -591,6 +591,11 @@ public:
 	 * Otherwise the document default font is used.
 	 */
 	virtual bool inheritFont() const { return true; }
+	/**
+	 * This method only applies to the screen font. It can be overriden
+	 * if output and screen font inheritance differ.
+	 */
+	virtual bool inheritScreenFont() const { return inheritFont(); }
 	/**
 	 * If this method returns true all explicitly set font attributes
 	 * are reset during editing operations.
diff --git a/src/insets/InsetFootlike.h b/src/insets/InsetFootlike.h
index e0a3fd31d0..fb53b33ee2 100644
--- a/src/insets/InsetFootlike.h
+++ b/src/insets/InsetFootlike.h
@@ -31,10 +31,10 @@ private:
 	void write(std::ostream & os) const override;
 	///
 	bool insetAllowed(InsetCode) const override;
-	/** returns false if, when outputting LaTeX, font changes should
-	    be closed before generating this inset. This is needed for
-	    insets that may contain several paragraphs */
-	bool inheritFont() const override { return false; }
+	/// Footnotes have InheritFont true (do not need to
+	/// explicitly reset fonts in output, but the screen font
+	/// differs from context
+	bool inheritScreenFont() const override { return false; }
 };
 
 

Attachment: signature.asc
Description: This is a digitally signed message part

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

Reply via email to