commit cfe094a380135f0e95ee859444f9c0b8e081c2e7
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Sun Jul 16 19:05:55 2023 +0200

    Introduce new InsetLayout tag InheritFont
    
    The font inside the inset is inherited from the parent for LaTeX
    export if this parameter is true, as well as on screen. Otherwise
    the document default font is used.
    
    The default value is true.
    
    Update tufte layouts to use this tag for sidenote and marginnote flex
    insets.
    
    Increase layout format to 101.
    
    Fixes bug #12238.
---
 lib/doc/Customization.lyx     |   57 ++++++++++++++++++++++++++++++++++++++++-
 lib/layouts/tufte-book.layout |   10 ++-----
 lib/scripts/layout2layout.py  |    7 +++-
 src/insets/Inset.h            |    2 +-
 src/insets/InsetLayout.cpp    |    5 +++
 src/insets/InsetLayout.h      |    4 +++
 6 files changed, 74 insertions(+), 11 deletions(-)

diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index dea9d98..411c74f 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 615
+\lyxformat 616
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -144,6 +144,7 @@ logicalmkup
 \author 177693 "x"
 \author 5863208 "ab"
 \author 34634807 "Jean-Pierre"
+\author 47243155 "Jean-Marc"
 \author 232239728 "Owner"
 \author 731793113 "Richard Kimberly Heck" rikih...@lyx.org
 \author 1075283030 "Thibaut"
@@ -21833,6 +21834,60 @@ nolink "false"
 \end_inset
 
 .
+\change_inserted 47243155 1689528605
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted 47243155 1689528735
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 47243155 1689528630
+InheritFont
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 47243155 1689528607
+0
+\end_layout
+
+\end_inset
+
+,
+\begin_inset space \thinspace{}
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 47243155 1689528607
+
+\emph on
+1
+\end_layout
+
+\end_inset
+
+] The font inside the inset is inherited from the parent for \SpecialChar LaTeX
+ export if this parameter is 1,
+ as well as on screen.
+ Otherwise the document default font is used.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
diff --git a/lib/layouts/tufte-book.layout b/lib/layouts/tufte-book.layout
index 5d8ab68..03d3338 100644
--- a/lib/layouts/tufte-book.layout
+++ b/lib/layouts/tufte-book.layout
@@ -162,6 +162,8 @@ InsetLayout Flex:Sidenote
        LatexName               sidenote
        Decoration              classic
        LabelString             "sidenote"
+       ResetsFont              true
+       InheritFont             false
        Font
          Color                 foreground
          Size                  Small
@@ -177,7 +179,6 @@ InsetLayout Flex:Sidenote
     DocBookAttr     role='sidenote'
        DocBookItemTag  para
     DocBookTagType  inline
-       ResetsFont              true
 End
 
 InsetLayout Flex:Marginnote
@@ -185,11 +186,6 @@ InsetLayout Flex:Marginnote
        LatexName               marginnote
        Decoration              classic
        LabelString             "marginnote"
-       Font
-         Family                Roman
-         Shape                 Up
-         Series                Medium
-       EndFont
     DocBookAttr     role='marginnote'
        MultiPar                true
 End
@@ -199,6 +195,7 @@ InsetLayout Flex:NewThought
        LatexType               Command
        LatexName               newthought
        LabelString             "new thought"
+       ResetsFont              true
        Font
          Shape                 SmallCaps
        EndFont
@@ -206,7 +203,6 @@ InsetLayout Flex:NewThought
          Family                Roman
          Color                 textlabel3
        EndFont
-       ResetsFont              true
        DocBookTag      emphasis
        DocBookAttr     role='newthought'
     DocBookTagType  inline
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index e718017..46a433c 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -11,7 +11,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 100
+currentFormat = 101
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -337,6 +337,9 @@ currentFormat = 100
 # Incremented to format 100, 9 May 2023 by forenr
 # Add inset label color
 
+# Incremented to format 101, 22 July 2023 by lasgouttes
+# add InsetLayout tag InheritFont
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -583,7 +586,7 @@ def convert(lines, end_format):
                 i += 1
             continue
 
-        if 87 <= format <= 100:
+        if 87 <= format <= 101:
             # nothing to do.
             i += 1
             continue
diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index 0ee6b12..1b7adb5 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -579,7 +579,7 @@ public:
         * LaTeX export if this method returns true, as well as on screen.
         * Otherwise the document default font is used.
         */
-       virtual bool inheritFont() const { return true; }
+       virtual bool inheritFont() const { return getLayout().inheritFont(); }
        /**
         * If this method returns true all explicitly set font attributes
         * are reset during editing operations.
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index 9636e10..ab6108a 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -113,6 +113,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & 
tclass,
                IL_DOCBOOKINNERATTR,
         IL_DOCBOOKNOFONTINSIDE,
         IL_DOCBOOKRENDERASIMAGE,
+               IL_INHERITFONT,
                IL_INTOC,
                IL_ISTOCCAPTION,
                IL_LABELFONT,
@@ -198,6 +199,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & 
tclass,
                { "htmlpreamble", IL_HTMLPREAMBLE },
                { "htmlstyle", IL_HTMLSTYLE },
                { "htmltag", IL_HTMLTAG },
+               { "inheritfont", IL_INHERITFONT },
                { "intoc", IL_INTOC },
                { "istoccaption", IL_ISTOCCAPTION },
                { "keepempty", IL_KEEPEMPTY },
@@ -339,6 +341,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & 
tclass,
                case IL_FORCEOWNLINES:
                        lex >> forceownlines_;
                        break;
+               case IL_INHERITFONT:
+                       lex >> inheritfont_;
+                       break;
                case IL_INTOC:
                        lex >> intoc_;
                        break;
diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h
index 4bf84c6..2342543 100644
--- a/src/insets/InsetLayout.h
+++ b/src/insets/InsetLayout.h
@@ -84,6 +84,8 @@ public:
        ///
        docstring rightdelim() const { return rightdelim_; }
        ///
+       bool inheritFont() const { return inheritfont_; }
+       ///
        FontInfo font() const { return font_; }
        ///
        FontInfo labelfont() const { return labelfont_; }
@@ -288,6 +290,8 @@ private:
        ///
        FontInfo labelfont_ = sane_font;
        ///
+       bool inheritfont_ = true;
+       ///
        ColorCode bgcolor_ = Color_error;
        ///
        docstring counter_;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to