commit 018a9bbb7c537e87ade0a12e5a0a1c95935c3e4d
Author: Juergen Spitzmueller <[email protected]>
Date:   Thu Aug 7 17:01:59 2025 +0200

    tex2lyx: fix resetting of local font change
    
    Only the first font switch at the beginning of groups was reset,
    e.g., {\huge\bfseries ...} only reset size, not series after
    the group.
    
    Spotted via #13183
---
 src/tex2lyx/Context.h |  2 ++
 src/tex2lyx/text.cpp  | 21 +++++++--------------
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/tex2lyx/Context.h b/src/tex2lyx/Context.h
index fe85d5d96b..940b14f647 100644
--- a/src/tex2lyx/Context.h
+++ b/src/tex2lyx/Context.h
@@ -178,6 +178,8 @@ public:
        Layout const * parent_layout;
        /// font attributes of this context
        TeXFont font;
+       /// font attributes of inner context
+       TeXFont inner_font;
        /// font attributes of normal text
        static TeXFont normalfont;
        /// Table rotation angle
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index deb85f428c..e9adae6467 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -115,6 +115,8 @@ void parse_text_snippet(Parser & p, ostream & os, unsigned 
flags, bool outer,
        // Make sure that we don't create invalid .lyx files
        context.need_layout = newcontext.need_layout;
        context.need_end_layout = newcontext.need_end_layout;
+       // store inner font
+       context.inner_font = newcontext.font;
 }
 
 
@@ -3572,32 +3574,28 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                                parse_text_snippet(p, os, FLAG_BRACE_LAST,
                                                   outer, context);
                                if (!context.atParagraphStart())
-                                       os << "\n\\size "
-                                          << context.font.size << "\n";
+                                       output_font_change(os, 
context.inner_font, context.font);
                        } else if (is_known(next.cs(), known_font_families)) {
                                // next will change the font family, so we
                                // must reset it here
                                parse_text_snippet(p, os, FLAG_BRACE_LAST,
                                                   outer, context);
                                if (!context.atParagraphStart())
-                                       os << "\n\\family "
-                                          << context.font.family << "\n";
+                                       output_font_change(os, 
context.inner_font, context.font);
                        } else if (is_known(next.cs(), known_font_series)) {
                                // next will change the font series, so we
                                // must reset it here
                                parse_text_snippet(p, os, FLAG_BRACE_LAST,
                                                   outer, context);
                                if (!context.atParagraphStart())
-                                       os << "\n\\series "
-                                          << context.font.series << "\n";
+                                       output_font_change(os, 
context.inner_font, context.font);
                        } else if (is_known(next.cs(), known_font_shapes)) {
                                // next will change the font shape, so we
                                // must reset it here
                                parse_text_snippet(p, os, FLAG_BRACE_LAST,
                                                   outer, context);
                                if (!context.atParagraphStart())
-                                       os << "\n\\shape "
-                                          << context.font.shape << "\n";
+                                       output_font_change(os, 
context.inner_font, context.font);
                        } else if (is_known(next.cs(), known_old_font_families) 
||
                                   is_known(next.cs(), known_old_font_series) ||
                                   is_known(next.cs(), known_old_font_shapes)) {
@@ -3606,12 +3604,7 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                                parse_text_snippet(p, os, FLAG_BRACE_LAST,
                                                   outer, context);
                                if (!context.atParagraphStart())
-                                       os <<  "\n\\family "
-                                          << context.font.family
-                                          << "\n\\series "
-                                          << context.font.series
-                                          << "\n\\shape "
-                                          << context.font.shape << "\n";
+                                       output_font_change(os, 
context.inner_font, context.font);
                        } else {
                                output_ert_inset(os, "{", context);
                                parse_text_snippet(p, os, FLAG_BRACE_LAST,
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to