From 6edade59aa2ad3f413b9c3f823c4b7cb1ff86acc Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Tue, 6 Aug 2019 19:27:49 +0200 Subject: [PATCH] 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"). --- lib/doc/Customization.lyx | 61 ++++++++++++++++++++++++++++++++++-- lib/doc/de/Customization.lyx | 47 ++++++++++++++++++++++++++- lib/scripts/layout2layout.py | 7 +++-- src/BufferParams.cpp | 2 +- src/TextClass.cpp | 12 +++++-- src/TextClass.h | 4 +++ 6 files changed, 124 insertions(+), 9 deletions(-) diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index b51fe1451e..952535801e 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 584 +\lyxformat 585 \begin_document \begin_header \save_transient_properties true @@ -11536,8 +11536,65 @@ status collapsed . -\change_inserted -712698321 1565102054 +\change_inserted -712698321 1565110196 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 \end_layout diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx index 9557599097..27ad41f605 100644 --- a/lib/doc/de/Customization.lyx +++ b/lib/doc/de/Customization.lyx @@ -1,5 +1,5 @@ #LyX 2.4 created this file. For more info see https://www.lyx.org/ -\lyxformat 584 +\lyxformat 585 \begin_document \begin_header \save_transient_properties true @@ -9677,6 +9677,51 @@ status collapsed \begin_inset Flex Code 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 Header \end_layout diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 4c9679f335..0009c54c92 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 = 77 +currentFormat = 78 # Incremented to format 4, 6 April 2007, lasgouttes @@ -259,6 +259,9 @@ currentFormat = 77 # New textclass tag PageSize (= default page size) # 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 # Manual (section "Declaring a new text class"). @@ -508,7 +511,7 @@ def convert(lines, end_format): i += 1 continue - if format >= 65 and format <= 76: + if format >= 65 and format <= 77: # nothing to do. i += 1 continue diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 40d59f920a..f964c8027b 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1617,7 +1617,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, if (tokenPos(tclass.opt_fontsize(), '|', fontsize) >= 0) { // 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 diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 5a36fce1fc..8b54a4cded 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -62,7 +62,7 @@ namespace lyx { // You should also run the development/tools/updatelayouts.py script, // 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 @@ -151,8 +151,8 @@ TextClass::TextClass() : loaded_(false), tex_class_avail_(false), opt_enginetype_("authoryear|numerical"), opt_fontsize_("10|11|12"), opt_pagesize_("default|a4paper|a5paper|b5paper|letterpaper|legalpaper|executivepaper"), - opt_pagestyle_("empty|plain|headings|fancy"), pagesize_("default"), pagestyle_("default"), - tablestyle_("default"), columns_(1), sides_(OneSide), secnumdepth_(3), + opt_pagestyle_("empty|plain|headings|fancy"), fontsize_format_("$$spt"), pagesize_("default"), + pagestyle_("default"), tablestyle_("default"), columns_(1), sides_(OneSide), secnumdepth_(3), tocdepth_(3), outputType_(LATEX), outputFormat_("latex"), has_output_format_(false), defaultfont_(sane_font), titletype_(TITLE_COMMAND_AFTER), titlename_("maketitle"), @@ -1004,6 +1004,7 @@ void TextClass::readClassOptions(Lexer & lexrc) { enum { CO_FONTSIZE = 1, + CO_FONTSIZE_FORMAT, CO_PAGESIZE, CO_PAGESTYLE, CO_OTHER, @@ -1014,6 +1015,7 @@ void TextClass::readClassOptions(Lexer & lexrc) LexerKeyword classOptionsTags[] = { {"end", CO_END }, {"fontsize", CO_FONTSIZE }, + {"fontsizeformat", CO_FONTSIZE_FORMAT }, {"header", CO_HEADER }, {"other", CO_OTHER }, {"pagesize", CO_PAGESIZE }, @@ -1036,6 +1038,10 @@ void TextClass::readClassOptions(Lexer & lexrc) lexrc.next(); opt_fontsize_ = rtrim(lexrc.getString()); break; + case CO_FONTSIZE_FORMAT: + lexrc.next(); + fontsize_format_ = rtrim(lexrc.getString()); + break; case CO_PAGESIZE: lexrc.next(); opt_pagesize_ = rtrim(lexrc.getString()); diff --git a/src/TextClass.h b/src/TextClass.h index f42b270326..1e8582b1f0 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -276,6 +276,8 @@ protected: std::string opt_pagestyle_; /// Specific class options std::string options_; + /// Format of the fontsize option + std::string fontsize_format_; /// Default page size std::string pagesize_; /// @@ -461,6 +463,8 @@ public: /// 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 & pagestyle() const { return pagestyle_; } -- 2.39.5