Add FontSizeFormat textclass option

This allows to customize the way fontsizes are passed to the class (e.g.,
"fontsize=12", as used by KOMA, rather than "12pt").
This commit is contained in:
Juergen Spitzmueller 2019-08-06 19:27:49 +02:00
parent cf614433d4
commit 50abaa0e57
6 changed files with 124 additions and 9 deletions

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/ #LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 584 \lyxformat 585
\begin_document \begin_document
\begin_header \begin_header
\save_transient_properties true \save_transient_properties true
@ -11536,8 +11536,65 @@ status collapsed
. .
\change_inserted -712698321 1565102054 \change_inserted -712698321 1565110196
Any number is possible. Any number is possible.
\end_layout
\begin_layout Description
\change_inserted -712698321 1565110259
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1565110199
FontSizeFormat
\end_layout
\end_inset
[
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1565110196
string
\end_layout
\end_inset
] The format for the font size option.
Default:
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1565110238
$$spt
\change_unchanged
\end_layout
\end_inset
.
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1565110248
$$s
\end_layout
\end_inset
is a placeholder for the font size.
\change_unchanged \change_unchanged
\end_layout \end_layout

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/ #LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 584 \lyxformat 585
\begin_document \begin_document
\begin_header \begin_header
\save_transient_properties true \save_transient_properties true
@ -9677,6 +9677,51 @@ status collapsed
\begin_inset Flex Code \begin_inset Flex Code
status collapsed status collapsed
\begin_layout Plain Layout
FontSizeFormat
\end_layout
\end_inset
[
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
string
\end_layout
\end_inset
] Das Format der Schriftgrößen-Option.
Voreinstellung:
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
$$spt
\end_layout
\end_inset
.
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
$$s
\end_layout
\end_inset
ist ein Platzhalter für die Schriftgröße.
\end_layout
\begin_layout Description
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout \begin_layout Plain Layout
Header Header
\end_layout \end_layout

View File

@ -11,7 +11,7 @@
# This script will update a .layout file to current format # This script will update a .layout file to current format
# The latest layout format is also defined in src/TextClass.cpp # The latest layout format is also defined in src/TextClass.cpp
currentFormat = 77 currentFormat = 78
# Incremented to format 4, 6 April 2007, lasgouttes # Incremented to format 4, 6 April 2007, lasgouttes
@ -259,6 +259,9 @@ currentFormat = 77
# New textclass tag PageSize (= default page size) # New textclass tag PageSize (= default page size)
# and textclass option PageSize (= list of available page sizes) # and textclass option PageSize (= list of available page sizes)
# Incremented to format 78, 6 August 2019 by spitz
# New textclass tag FontsizeFormat
# Do not forget to document format change in Customization # Do not forget to document format change in Customization
# Manual (section "Declaring a new text class"). # Manual (section "Declaring a new text class").
@ -508,7 +511,7 @@ def convert(lines, end_format):
i += 1 i += 1
continue continue
if format >= 65 and format <= 76: if format >= 65 and format <= 77:
# nothing to do. # nothing to do.
i += 1 i += 1
continue continue

View File

@ -1617,7 +1617,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
if (tokenPos(tclass.opt_fontsize(), if (tokenPos(tclass.opt_fontsize(),
'|', fontsize) >= 0) { '|', fontsize) >= 0) {
// only write if existing in list (and not default) // only write if existing in list (and not default)
clsoptions << fontsize << "pt,"; clsoptions << subst(tclass.fontsizeformat(), "$$s", fontsize) << ",";
} }
// paper sizes not supported by the class itself need the // paper sizes not supported by the class itself need the

View File

@ -62,7 +62,7 @@ namespace lyx {
// You should also run the development/tools/updatelayouts.py script, // You should also run the development/tools/updatelayouts.py script,
// to update the format of all of our layout files. // to update the format of all of our layout files.
// //
int const LAYOUT_FORMAT = 77; // spitz: pagesize int const LAYOUT_FORMAT = 78; // spitz: FontsizeFormat
// Layout format for the current lyx file format. Controls which format is // Layout format for the current lyx file format. Controls which format is
@ -151,8 +151,8 @@ TextClass::TextClass()
: loaded_(false), tex_class_avail_(false), : loaded_(false), tex_class_avail_(false),
opt_enginetype_("authoryear|numerical"), opt_fontsize_("10|11|12"), opt_enginetype_("authoryear|numerical"), opt_fontsize_("10|11|12"),
opt_pagesize_("default|a4paper|a5paper|b5paper|letterpaper|legalpaper|executivepaper"), opt_pagesize_("default|a4paper|a5paper|b5paper|letterpaper|legalpaper|executivepaper"),
opt_pagestyle_("empty|plain|headings|fancy"), pagesize_("default"), pagestyle_("default"), opt_pagestyle_("empty|plain|headings|fancy"), fontsize_format_("$$spt"), pagesize_("default"),
tablestyle_("default"), columns_(1), sides_(OneSide), secnumdepth_(3), pagestyle_("default"), tablestyle_("default"), columns_(1), sides_(OneSide), secnumdepth_(3),
tocdepth_(3), outputType_(LATEX), outputFormat_("latex"), tocdepth_(3), outputType_(LATEX), outputFormat_("latex"),
has_output_format_(false), defaultfont_(sane_font), has_output_format_(false), defaultfont_(sane_font),
titletype_(TITLE_COMMAND_AFTER), titlename_("maketitle"), titletype_(TITLE_COMMAND_AFTER), titlename_("maketitle"),
@ -1004,6 +1004,7 @@ void TextClass::readClassOptions(Lexer & lexrc)
{ {
enum { enum {
CO_FONTSIZE = 1, CO_FONTSIZE = 1,
CO_FONTSIZE_FORMAT,
CO_PAGESIZE, CO_PAGESIZE,
CO_PAGESTYLE, CO_PAGESTYLE,
CO_OTHER, CO_OTHER,
@ -1014,6 +1015,7 @@ void TextClass::readClassOptions(Lexer & lexrc)
LexerKeyword classOptionsTags[] = { LexerKeyword classOptionsTags[] = {
{"end", CO_END }, {"end", CO_END },
{"fontsize", CO_FONTSIZE }, {"fontsize", CO_FONTSIZE },
{"fontsizeformat", CO_FONTSIZE_FORMAT },
{"header", CO_HEADER }, {"header", CO_HEADER },
{"other", CO_OTHER }, {"other", CO_OTHER },
{"pagesize", CO_PAGESIZE }, {"pagesize", CO_PAGESIZE },
@ -1036,6 +1038,10 @@ void TextClass::readClassOptions(Lexer & lexrc)
lexrc.next(); lexrc.next();
opt_fontsize_ = rtrim(lexrc.getString()); opt_fontsize_ = rtrim(lexrc.getString());
break; break;
case CO_FONTSIZE_FORMAT:
lexrc.next();
fontsize_format_ = rtrim(lexrc.getString());
break;
case CO_PAGESIZE: case CO_PAGESIZE:
lexrc.next(); lexrc.next();
opt_pagesize_ = rtrim(lexrc.getString()); opt_pagesize_ = rtrim(lexrc.getString());

View File

@ -276,6 +276,8 @@ protected:
std::string opt_pagestyle_; std::string opt_pagestyle_;
/// Specific class options /// Specific class options
std::string options_; std::string options_;
/// Format of the fontsize option
std::string fontsize_format_;
/// Default page size /// Default page size
std::string pagesize_; std::string pagesize_;
/// ///
@ -461,6 +463,8 @@ public:
/// ///
std::string const & class_header() const { return class_header_; } std::string const & class_header() const { return class_header_; }
/// ///
std::string const & fontsizeformat() const { return fontsize_format_; }
///
std::string const & pagesize() const { return pagesize_; } std::string const & pagesize() const { return pagesize_; }
/// ///
std::string const & pagestyle() const { return pagestyle_; } std::string const & pagestyle() const { return pagestyle_; }