commit 97a099b1379e041c457f9e78253f544d85f87916
Author: Kornel Benko <kor...@lyx.org>
Date:   Sun Jul 14 21:44:58 2019 +0200

    Add sans serif font "cantarell"
---
 lib/chkconfig.ltx      |    1 +
 lib/latexfonts         |   22 ++++++++++++++++++++++
 lib/lyx2lyx/lyx_2_4.py |   41 +++++++++++++++++++++++++++++++++++++++--
 src/version.h          |    4 ++--
 4 files changed, 64 insertions(+), 4 deletions(-)

diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx
index bf357b6..b764370 100644
--- a/lib/chkconfig.ltx
+++ b/lib/chkconfig.ltx
@@ -474,6 +474,7 @@
 \TestPackage{biolinum}
 \TestPackage{biolinum-type1}
 %\TestFont[glic1000]{cbgreek}% for Greek % suported by LyX but too large to 
force downloading
+\TestPackage{cantarell}
 \TestPackage{ccfonts}
 \TestFont[ccr10]{concrete} % required by ccfonts
 \TestFont[eorm10]{ecc} % required by ccfonts
diff --git a/lib/latexfonts b/lib/latexfonts
index 10b9886..c5a6f75 100644
--- a/lib/latexfonts
+++ b/lib/latexfonts
@@ -654,6 +654,28 @@ AltFont biolinum-2012
        MoreOptions      1
 EndFont
 
+Font cantarell
+       GuiName         "Cantarell Sans Serif"
+       Family          sf
+       OsfOption       oldstyle
+       Package         cantarell
+       PackageOption   "defaultsans"
+       MoreOptions      1
+       FontEncoding    T2A,T1,OT1
+       ScaleOption     scale=$$val
+       AltFonts        cantarell1
+EndFont
+
+AltFont cantarell1
+       GuiName         "Cantarell Sans Serif"
+       Family          sf
+       OsfOption       oldstyle
+       OsfDefault      0
+       Package         cantarell
+       ScaleOption     scale=$$val
+       FontEncoding    T2A,T1,OT1
+EndFont
+
 Font cmbr
        GuiName          "CM Bright"
        Family           sf
diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
index e0f38ed..b555851 100644
--- a/lib/lyx2lyx/lyx_2_4.py
+++ b/lib/lyx2lyx/lyx_2_4.py
@@ -173,6 +173,9 @@ def createFontMapping(fontlist):
                                   'NotoSansExtralight,extralight'],
                                   "sans", "sf", "noto-sans", "scaled")
             fm.expandFontMapping(['NotoMonoRegular,regular'], "typewriter", 
"tt", "noto-mono", "scaled")
+        elif font == 'Cantarell':
+            fm.expandFontMapping(['cantarell,defaultsans'],
+                                  "sans", "sf", "cantarell", "scaled", 
"oldstyle")
     return fm
 
 def convert_fonts(document, fm):
@@ -383,6 +386,22 @@ def revert_AdobeFonts(document):
         if revert_fonts(document, fm, fontmap):
             add_preamble_fonts(document, fontmap)
 
+def convert_CantarellFont(document):
+    " Handle Cantarell font definition to LaTeX "
+
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
+        fm = createFontMapping(['Cantarell'])
+        convert_fonts(document, fm)
+
+def revert_CantarellFont(document):
+    " Revert native Cantarell font definition to LaTeX "
+
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
+        fontmap = dict()
+        fm = createFontMapping(['Cantarell'])
+        if revert_fonts(document, fm, fontmap, True):
+            add_preamble_fonts(document, fontmap)
+
 def removeFrontMatterStyles(document):
     " Remove styles Begin/EndFrontmatter"
 
@@ -2623,6 +2642,22 @@ def revert_AdobeFonts_xopts(document):
         add_preamble_fonts(document, fontmap)
 
 
+def revert_CantarellFont_xopts(document):
+    " Revert native (extended) Cantarell font definition (with extra options) 
to LaTeX "
+
+    i = find_token(document.header, '\\use_non_tex_fonts', 0)
+    if i == -1:
+        document.warning("Malformed LyX document: Missing 
\\use_non_tex_fonts.")
+        return
+    if str2bool(get_value(document.header, "\\use_non_tex_fonts", i)):
+        return
+
+    fontmap = dict()
+    fm = createFontMapping(['Cantarell'])
+    if revert_fonts(document, fm, fontmap, True):
+        add_preamble_fonts(document, fontmap)
+
+
 def convert_osf(document):
     " Convert \\font_osf param to new format "
 
@@ -2882,10 +2917,12 @@ convert = [
            [578, []],
            [579, []],
            [580, []],
-           [581, [convert_osf]]
+           [581, [convert_osf]],
+           [582, [convert_CantarellFont]],
           ]
 
-revert =  [[580, [revert_texfontopts,revert_osf]],
+revert =  [[581, [revert_CantarellFont, revert_CantarellFont_xopts]],
+           [580, [revert_texfontopts,revert_osf]],
            [579, [revert_minionpro, revert_plainNotoFonts_xopts, 
revert_notoFonts_xopts, revert_IBMFonts_xopts, revert_AdobeFonts_xopts, 
revert_font_opts]], # keep revert_font_opts last!
            [578, [revert_babelfont]],
            [577, [revert_drs]],
diff --git a/src/version.h b/src/version.h
index e42b7a8..1fb7c5d 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 581 // spitz: split osf to font families
-#define LYX_FORMAT_TEX2LYX 581
+#define LYX_FORMAT_LYX 582 // Kornel: Add cantarell sans serif font
+#define LYX_FORMAT_TEX2LYX 582
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER

Reply via email to