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.
This commit is contained in:
Jean-Marc Lasgouttes 2023-07-16 19:05:55 +02:00
parent c8c589353a
commit cfe094a380
6 changed files with 74 additions and 11 deletions

View File

@ -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" rikiheck@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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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;

View File

@ -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_;