[LyX/master] Allow defaultfamily change with non_TeX fonts (#12608)

Juergen Spitzmueller spitz at lyx.org
Sun Dec 11 12:51:24 UTC 2022


commit 163844a6d0f287ceb9aa2f82da4bbf33448dbeed
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sun Dec 11 14:46:10 2022 +0100

    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 +-
 src/tex2lyx/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 ba4ea20..1003fa0 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 <spitz at lyx.org> 
+	* Format incremented to 613: Support \\fonts_default_family for non-TeX fonts.
+
 2022-12-04 Daniel Ramöller <d.lyx at web.de>
 	* 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 e75cdbf..e0db0d6 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 beaed5c..6a62219 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 661dd30..fa59b3f 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 a09ffde..050689e 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 37322e8..8bb9ae2 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 7386c08..54b14cc 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 234b7f8..0e392bf 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 0edbb2f..843262c 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 3a96a2f..55f6297 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 bac468f..5631c94 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 678320a..ac5850a 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 542e131..13ab5f4 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 4c9f57e..da3150e 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 c859625..dc30a21 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 980c3ea..b58641f 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 a9f621a..6e470f4 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 f54592b..2445b75 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 3fb61a2..c86ea68 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 e13e9b8..f49e901 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 9997030..b47591b 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 8b1d6fd..8484f04 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 35c5651..c3b4dff 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 a643509..c14f36d 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


More information about the lyx-cvs mailing list