From 163844a6d0f287ceb9aa2f82da4bbf33448dbeed Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sun, 11 Dec 2022 14:46:10 +0100 Subject: [PATCH] Allow defaultfamily change with non_TeX fonts (#12608) --- development/FORMAT | 3 ++ lib/lyx2lyx/lyx_2_4.py | 28 +++++++++++++++++-- src/frontends/qt/GuiDocument.cpp | 9 ++---- src/tex2lyx/test/CJK.lyx.lyx | 2 +- src/tex2lyx/test/CJKutf8.lyx.lyx | 2 +- src/tex2lyx/test/DummyDocument.lyx.lyx | 2 +- src/tex2lyx/test/Dummy~Document.lyx.lyx | 2 +- src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx | 2 +- src/tex2lyx/test/algo2e.lyx.lyx | 2 +- src/tex2lyx/test/beamer.lyx.lyx | 2 +- .../test/box-color-size-space-align.lyx.lyx | 2 +- src/tex2lyx/test/listpreamble.lyx.lyx | 2 +- src/tex2lyx/test/tabular-x-test.lyx.lyx | 2 +- src/tex2lyx/test/test-insets-basic.lyx.lyx | 2 +- src/tex2lyx/test/test-insets.lyx.lyx | 2 +- src/tex2lyx/test/test-memoir.lyx.lyx | 2 +- src/tex2lyx/test/test-minted.lyx.lyx | 2 +- src/tex2lyx/test/test-modules.lyx.lyx | 2 +- .../test/test-refstyle-theorems.lyx.lyx | 2 +- src/tex2lyx/test/test-scr.lyx.lyx | 2 +- src/tex2lyx/test/test-structure.lyx.lyx | 2 +- src/tex2lyx/test/test.lyx.lyx | 2 +- src/tex2lyx/test/verbatim.lyx.lyx | 2 +- src/version.h | 4 +-- 24 files changed, 52 insertions(+), 32 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index ba4ea20f71..1003fa0774 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -7,6 +7,9 @@ changes happened in particular if possible. A good example would be ----------------------- +2022-12-11 Jürgen Spitzmüller + * Format incremented to 613: Support \\fonts_default_family for non-TeX fonts. + 2022-12-04 Daniel Ramöller * Format incremented to 612: Implement support for starred crossref commands (with hyperref) which suppress links: diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index e75cdbf2c4..e0db0d6009 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -4540,6 +4540,7 @@ def revert_index_macros(document): def revert_starred_refs(document): + " Revert starred refs " i = find_token(document.header, "\\use_hyperref true", 0) use_hyperref = (i != -1) i = 0 @@ -4604,6 +4605,7 @@ def revert_starred_refs(document): def convert_starred_refs(document): + " Convert inset index macros " i = 0 while True: i = find_token(document.body, "\\begin_inset CommandInset ref", i) @@ -4617,7 +4619,25 @@ def convert_starred_refs(document): newlineat = end - 2 document.body.insert(newlineat, "nolink \"false\"") i = end + 1 - + + +def revert_familydefault(document): + " Revert \\font_default_family for non-TeX fonts " + + if find_token(document.header, "\\use_non_tex_fonts true", 0) == -1: + return + + i = find_token(document.header, "\\font_default_family", 0) + if i == -1: + document.warning("Malformed LyX document: Can't find \\font_default_family header") + return + + dfamily = get_value(document.header, "\\font_default_family", i) + if dfamily == "default": + return + + document.header[i] = "\\font_default_family default" + add_to_preamble(document, ["\\renewcommand{\\familydefault}{\\" + dfamily + "}"]) ## # Conversion hub @@ -4692,10 +4712,12 @@ convert = [ [609, []], [610, []], [611, []], - [612, [convert_starred_refs]] + [612, [convert_starred_refs]], + [613, []] ] -revert = [[611, [revert_starred_refs]], +revert = [[612, [revert_familydefault]], + [611, [revert_starred_refs]], [610, []], [609, [revert_index_macros]], [608, [revert_document_metadata]], diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp index beaed5cf9b..6a6221915e 100644 --- a/src/frontends/qt/GuiDocument.cpp +++ b/src/frontends/qt/GuiDocument.cpp @@ -2448,8 +2448,6 @@ void GuiDocument::osFontsChanged(bool nontexfonts) langModule->encodingCO->setEnabled(tex_fonts); inputencodingToDialog(); - fontModule->fontsDefaultCO->setEnabled(tex_fonts); - fontModule->fontsDefaultLA->setEnabled(tex_fonts); fontModule->cjkFontLE->setEnabled(tex_fonts); fontModule->cjkFontLA->setEnabled(tex_fonts); @@ -3864,11 +3862,8 @@ void GuiDocument::applyView() bp_.fonts_sans_osf = fontModule->fontSansOsfCB->isChecked(); bp_.fonts_typewriter_osf = fontModule->fontTypewriterOsfCB->isChecked(); - if (nontexfonts) - bp_.fonts_default_family = "default"; - else - bp_.fonts_default_family = GuiDocument::fontfamilies[ - fontModule->fontsDefaultCO->currentIndex()]; + bp_.fonts_default_family = GuiDocument::fontfamilies[ + fontModule->fontsDefaultCO->currentIndex()]; if (fontModule->fontsizeCO->currentIndex() == 0) bp_.fontsize = "default"; diff --git a/src/tex2lyx/test/CJK.lyx.lyx b/src/tex2lyx/test/CJK.lyx.lyx index 661dd30e64..fa59b3f976 100644 --- a/src/tex2lyx/test/CJK.lyx.lyx +++ b/src/tex2lyx/test/CJK.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/CJKutf8.lyx.lyx b/src/tex2lyx/test/CJKutf8.lyx.lyx index a09ffde8d0..050689e5ad 100644 --- a/src/tex2lyx/test/CJKutf8.lyx.lyx +++ b/src/tex2lyx/test/CJKutf8.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/DummyDocument.lyx.lyx b/src/tex2lyx/test/DummyDocument.lyx.lyx index 37322e8a89..8bb9ae29f5 100644 --- a/src/tex2lyx/test/DummyDocument.lyx.lyx +++ b/src/tex2lyx/test/DummyDocument.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/Dummy~Document.lyx.lyx b/src/tex2lyx/test/Dummy~Document.lyx.lyx index 7386c081e7..54b14ccccb 100644 --- a/src/tex2lyx/test/Dummy~Document.lyx.lyx +++ b/src/tex2lyx/test/Dummy~Document.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx index 234b7f8552..0e392bfdd0 100644 --- a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx +++ b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/algo2e.lyx.lyx b/src/tex2lyx/test/algo2e.lyx.lyx index 0edbb2f1e6..843262cddd 100644 --- a/src/tex2lyx/test/algo2e.lyx.lyx +++ b/src/tex2lyx/test/algo2e.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/beamer.lyx.lyx b/src/tex2lyx/test/beamer.lyx.lyx index 3a96a2fb37..55f6297b16 100644 --- a/src/tex2lyx/test/beamer.lyx.lyx +++ b/src/tex2lyx/test/beamer.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx index bac468ff2b..5631c94616 100644 --- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx +++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/listpreamble.lyx.lyx b/src/tex2lyx/test/listpreamble.lyx.lyx index 678320a836..ac5850a09f 100644 --- a/src/tex2lyx/test/listpreamble.lyx.lyx +++ b/src/tex2lyx/test/listpreamble.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/tabular-x-test.lyx.lyx b/src/tex2lyx/test/tabular-x-test.lyx.lyx index 542e131ffc..13ab5f440b 100644 --- a/src/tex2lyx/test/tabular-x-test.lyx.lyx +++ b/src/tex2lyx/test/tabular-x-test.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/test-insets-basic.lyx.lyx b/src/tex2lyx/test/test-insets-basic.lyx.lyx index 4c9f57ec97..da3150e96e 100644 --- a/src/tex2lyx/test/test-insets-basic.lyx.lyx +++ b/src/tex2lyx/test/test-insets-basic.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/test-insets.lyx.lyx b/src/tex2lyx/test/test-insets.lyx.lyx index c8596257ce..dc30a2169e 100644 --- a/src/tex2lyx/test/test-insets.lyx.lyx +++ b/src/tex2lyx/test/test-insets.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/test-memoir.lyx.lyx b/src/tex2lyx/test/test-memoir.lyx.lyx index 980c3eaa6e..b58641fb48 100644 --- a/src/tex2lyx/test/test-memoir.lyx.lyx +++ b/src/tex2lyx/test/test-memoir.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/test-minted.lyx.lyx b/src/tex2lyx/test/test-minted.lyx.lyx index a9f621a393..6e470f478b 100644 --- a/src/tex2lyx/test/test-minted.lyx.lyx +++ b/src/tex2lyx/test/test-minted.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/test-modules.lyx.lyx b/src/tex2lyx/test/test-modules.lyx.lyx index f54592b856..2445b75986 100644 --- a/src/tex2lyx/test/test-modules.lyx.lyx +++ b/src/tex2lyx/test/test-modules.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx index 3fb61a2610..c86ea68bea 100644 --- a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx +++ b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/test-scr.lyx.lyx b/src/tex2lyx/test/test-scr.lyx.lyx index e13e9b86bc..f49e9018f4 100644 --- a/src/tex2lyx/test/test-scr.lyx.lyx +++ b/src/tex2lyx/test/test-scr.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/test-structure.lyx.lyx b/src/tex2lyx/test/test-structure.lyx.lyx index 9997030332..b47591bb0e 100644 --- a/src/tex2lyx/test/test-structure.lyx.lyx +++ b/src/tex2lyx/test/test-structure.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/test.lyx.lyx b/src/tex2lyx/test/test.lyx.lyx index 8b1d6fd1fe..8484f04213 100644 --- a/src/tex2lyx/test/test.lyx.lyx +++ b/src/tex2lyx/test/test.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/tex2lyx/test/verbatim.lyx.lyx b/src/tex2lyx/test/verbatim.lyx.lyx index 35c5651889..c3b4dffc02 100644 --- a/src/tex2lyx/test/verbatim.lyx.lyx +++ b/src/tex2lyx/test/verbatim.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.4 -\lyxformat 612 +\lyxformat 613 \begin_document \begin_header \save_transient_properties true diff --git a/src/version.h b/src/version.h index a643509834..c14f36db62 100644 --- a/src/version.h +++ b/src/version.h @@ -32,8 +32,8 @@ extern char const * const lyx_version_info; // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -#define LYX_FORMAT_LYX 612 // RKH & DR: Starred cross-references -#define LYX_FORMAT_TEX2LYX 612 +#define LYX_FORMAT_LYX 613 // spitz: \defaultfamily for non-TeX fonts +#define LYX_FORMAT_TEX2LYX 613 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER