[LyX/master] Make TextMetrics::font_ mutable

Jean-Marc Lasgouttes <[email protected]>
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit 84aa10e96a21866bbeb2afd986746b917acb1abd
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Tue Mar 10 18:45:27 2026 +0100

    Make TextMetrics::font_ mutable
    
    This is only a cache, set when computing metrics. I could maybe be set when running updateBuffer().
    
    Anyway, this is a cache, so makeing it mutable makes sense.
    
    Later, this should be moved to Text and the code should be cleaned up.
    None of that requires a BufferView.
---
 src/TextMetrics.h        | 7 +++----
 src/insets/InsetText.cpp | 4 ++--
 src/insets/InsetText.h   | 2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/TextMetrics.h b/src/TextMetrics.h
index 106d4cb04f..6f283617d1 100644
--- a/src/TextMetrics.h
+++ b/src/TextMetrics.h
@@ -281,10 +281,9 @@ public:
 	/// our 'outermost' font.
 	/// This is handed down from the surrounding
 	/// inset through the pi/mi parameter (pi.base.font)
-	/// It is used in applyOuterFont() and setCharFont() for reasons
-	/// that are not clear... to hand hand the outermost language and
-	/// also for char style apparently.
-	Font font_;
+	/// It is used in applyOuterFont(), Text::insertChar() and Text::setFont().
+	// FIXME: move to Text
+	mutable Font font_;
 };
 
 /// return the default height of a row in pixels, considering font zoom
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 6e5b97fdaa..f01b0fbf3c 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -194,9 +194,9 @@ void InsetText::read(Lexer & lex)
 }
 
 
-void InsetText::setOuterFont(BufferView & bv, FontInfo const & outer) const
+void InsetText::setOuterFont(BufferView const & bv, FontInfo const & outer) const
 {
-	TextMetrics & tm = bv.textMetrics(&text_);
+	TextMetrics const & tm = bv.textMetrics(&text_);
 	FontInfo tmpfont = getFont();
 	tmpfont.realize(outer);
 	tm.font_.fontInfo() = tmpfont;
diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h
index f5399296a8..94bbea184d 100644
--- a/src/insets/InsetText.h
+++ b/src/insets/InsetText.h
@@ -57,7 +57,7 @@ public:
 	///
 	void write(std::ostream & os) const override;
 	/// Let the inset compute and store its reference font from \c outer.
-	void setOuterFont(BufferView & bv, FontInfo const & outer) const;
+	void setOuterFont(BufferView const & bv, FontInfo const & outer) const;
 	///
 	void metrics(MetricsInfo & mi, Dimension & dim) const override;
 	///
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.