commit ed7072985e6a76a8013ea670728fc40e6359c723
Author: Thibaut Cuvelier <[email protected]>
Date:   Mon Dec 26 02:45:03 2022 +0100

    DocBook: for computing font changes, simplify code by removing state 
evolution from iteration to iteration. This surely makes the code slightly 
slower (although the compiler should be smart enough), but (much) easier to 
reason about.
---
 src/Paragraph.cpp |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 9c3b0dc..8650826 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3568,8 +3568,6 @@ std::tuple<std::vector<docstring>, 
std::vector<docstring>, std::vector<docstring
     DocBookFontState old_fs = fs;
 
     Layout const & style = *d->layout_;
-    FontInfo font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : 
style.font;
-    string const default_family = 
buf.masterBuffer()->params().fonts_default_family;
 
        // Conversion of the font opening/closing into DocBook tags.
     vector<xml::FontTag> tagsToOpen;
@@ -3602,14 +3600,17 @@ std::tuple<std::vector<docstring>, 
std::vector<docstring>, std::vector<docstring
 
                        // Restore the fonts for the new paragraph, so that the 
right tags are opened for the new entry.
                        if (!ignore_fonts_i) {
-                               font_old = outerfont.fontInfo();
                                fs = old_fs;
                        }
                }
 
                // Determine which tags should be opened or closed regarding 
fonts.
+               FontInfo const font_old = (i == 0 ?
+                               (style.labeltype == LABEL_MANUAL ? 
style.labelfont : style.font) :
+                               getFont(buf.masterBuffer()->params(), i - 1, 
outerfont).fontInfo());
                Font const font = getFont(buf.masterBuffer()->params(), i, 
outerfont);
-        tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(font_old, 
font, default_family, fs);
+        tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(
+                               font_old, font, 
buf.masterBuffer()->params().fonts_default_family, fs);
 
                if (!ignore_fonts_i) {
             vector<xml::EndFontTag>::const_iterator cit = tagsToClose.begin();
@@ -3665,7 +3666,6 @@ std::tuple<std::vector<docstring>, 
std::vector<docstring>, std::vector<docstring
                                        *xs << c;
                        }
                }
-               font_old = font.fontInfo();
        }
 
        // FIXME, this code is just imported from XHTML
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to