]> git.lyx.org Git - features.git/commitdiff
Remove Plex Semibolds
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 18 Jul 2019 06:14:09 +0000 (08:14 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:37 +0000 (15:48 +0200)
These are not font shapes proper. The semibold is to be combined with
font shapes and thus needs to go to extra options.

lib/latexfonts
lib/lyx2lyx/lyx_2_4.py
src/tex2lyx/Preamble.cpp

index 33ae9da299c5b68cb0d3dff3d6d3b2d86fabf9f9..9b75744b6865a08dd3a385e50781114bfe02527a 100644 (file)
@@ -202,14 +202,6 @@ Font IBMPlexSerifLight
        MoreOptions      1
 EndFont
 
-Font IBMPlexSerifSemibold
-       GuiName          "IBM Plex Serif (Semibold)"
-       Family           rm
-       Package          plex-serif
-       PackageOptions   semibold
-       MoreOptions      1
-EndFont
-
 Font ADOBESourceSerifPro
        GuiName          "Adobe Source Serif Pro"
        Family           rm
@@ -839,15 +831,6 @@ Font IBMPlexSansLight
        MoreOptions      1
 EndFont
 
-Font IBMPlexSansSemibold
-       GuiName          "IBM Plex Sans (Semibold)"
-       Family           sf
-       Package          plex-sans
-       PackageOptions   semibold
-       ScaleOption      scale=$$val
-       MoreOptions      1
-EndFont
-
 Font ADOBESourceSansPro
        GuiName          "Adobe Source Sans Pro"
        Family           sf
@@ -1103,15 +1086,6 @@ Font IBMPlexMonoLight
        MoreOptions      1
 EndFont
 
-Font IBMPlexMonoSemibold
-       GuiName          "IBM Plex Mono (Semibold)"
-       Family           tt
-       Package          plex-mono
-       ScaleOption      scale=$$val
-       PackageOptions   semibold
-       MoreOptions      1
-EndFont
-
 Font ADOBESourceCodePro
        GuiName          "Adobe Source Code Pro"
        Family           tt
index d7831dc5b6991fad491d72466a970b46827115fa..61066ab8cca6559844cd5fae9052cfcebbc7316d 100644 (file)
@@ -2956,6 +2956,97 @@ def revert_FiraFont(document):
             add_preamble_fonts(document, fontmap)
 
 
+def convert_Semibolds(document):
+    " Move semibold options to extraopts "
+
+    NonTeXFonts = False
+    i = find_token(document.header, '\\use_non_tex_fonts', 0)
+    if i == -1:
+        document.warning("Malformed LyX document: Missing \\use_non_tex_fonts.")
+    else:
+        NonTeXFonts = str2bool(get_value(document.header, "\\use_non_tex_fonts", i))
+
+    sbfonts = ["IBMPlexSerifSemibold", "IBMPlexSansSemibold", "IBMPlexMonoSemibold" ]
+
+    i = find_token(document.header, "\\font_roman", 0)
+    if i == -1:
+        document.warning("Malformed LyX document: Missing \\font_roman.")
+    else:
+        # We need to use this regex since split() does not handle quote protection
+        romanfont = re.findall(r'[^"\s]\S*|".+?"', document.header[i])
+        roman = romanfont[1].strip('"')
+        if roman == "IBMPlexSerifSemibold":
+            romanfont[1] = '"IBMPlexSerif"'
+            document.header[i] = " ".join(romanfont)
+
+            if NonTeXFonts == False:
+                regexp = re.compile(r'(\\font_roman_opts)')
+                x = find_re(document.header, regexp, 0)
+                if x == -1:
+                    # Sensible place to insert tag
+                    fo = find_token(document.header, "\\font_sf_scale")
+                    if fo == -1:
+                        document.warning("Malformed LyX document! Missing \\font_sf_scale")
+                    else:
+                        document.header.insert(fo, "\\font_roman_opts \"semibold\"")
+                else:
+                    # We need to use this regex since split() does not handle quote protection
+                    romanopts = re.findall(r'[^"\s]\S*|".+?"', document.header[x])
+                    document.header[x] = "\\font_roman_opts \"semibold, " + romanopts[1].strip('"') + "\""
+
+    i = find_token(document.header, "\\font_sans", 0)
+    if i == -1:
+        document.warning("Malformed LyX document: Missing \\font_sans.")
+    else:
+        # We need to use this regex since split() does not handle quote protection
+        sffont = re.findall(r'[^"\s]\S*|".+?"', document.header[i])
+        sf = sffont[1].strip('"')
+        if sf == "IBMPlexSansSemibold":
+            sffont[1] = '"IBMPlexSans"'
+            document.header[i] = " ".join(sffont)
+
+            if NonTeXFonts == False:
+                regexp = re.compile(r'(\\font_sans_opts)')
+                x = find_re(document.header, regexp, 0)
+                if x == -1:
+                    # Sensible place to insert tag
+                    fo = find_token(document.header, "\\font_sf_scale")
+                    if fo == -1:
+                        document.warning("Malformed LyX document! Missing \\font_sf_scale")
+                    else:
+                        document.header.insert(fo, "\\font_sans_opts \"semibold\"")
+                else:
+                    # We need to use this regex since split() does not handle quote protection
+                    sfopts = re.findall(r'[^"\s]\S*|".+?"', document.header[x])
+                    document.header[x] = "\\font_sans_opts \"semibold, " + sfopts[1].strip('"') + "\""
+
+    i = find_token(document.header, "\\font_typewriter", 0)
+    if i == -1:
+        document.warning("Malformed LyX document: Missing \\font_typewriter.")
+    else:
+        # We need to use this regex since split() does not handle quote protection
+        ttfont = re.findall(r'[^"\s]\S*|".+?"', document.header[i])
+        tt = ttfont[1].strip('"')
+        if tt == "IBMPlexMonoSemibold":
+            ttfont[1] = '"IBMPlexMono"'
+            document.header[i] = " ".join(ttfont)
+
+            if NonTeXFonts == False:
+                regexp = re.compile(r'(\\font_typewriter_opts)')
+                x = find_re(document.header, regexp, 0)
+                if x == -1:
+                    # Sensible place to insert tag
+                    fo = find_token(document.header, "\\font_tt_scale")
+                    if fo == -1:
+                        document.warning("Malformed LyX document! Missing \\font_tt_scale")
+                    else:
+                        document.header.insert(fo, "\\font_typewriter_opts \"semibold\"")
+                else:
+                    # We need to use this regex since split() does not handle quote protection
+                    ttopts = re.findall(r'[^"\s]\S*|".+?"', document.header[x])
+                    document.header[x] = "\\font_typewriter_opts \"semibold, " + sfopts[1].strip('"') + "\""
+
+
 ##
 # Conversion hub
 #
@@ -3000,7 +3091,7 @@ convert = [
            [580, []],
            [581, [convert_osf]],
            [582, [convert_AdobeFonts,convert_latexFonts,convert_notoFonts,convert_CantarellFont,convert_FiraFont]],# old font re-converterted due to extra options
-           [583, [convert_ChivoFont]],
+           [583, [convert_ChivoFont,convert_Semibolds]],
           ]
 
 revert =  [[582, [revert_ChivoFont]],
index ea76e5f8c513dca7384827208b0cfa0a0a29f669..2ab24e11c138a914214a960031cff2180f247e39 100644 (file)
@@ -1019,10 +1019,6 @@ void Preamble::handle_package(Parser &p, string const & name,
                                h_font_roman[0] = "IBMPlexSerifLight";
                                continue;
                        }
-                       if (opt == "semibold") {
-                               h_font_roman[0] = "IBMPlexSerifSemibold";
-                               continue;
-                       }
                        if (!xopts.empty())
                                xopts += ", ";
                        xopts += opt;
@@ -1228,10 +1224,6 @@ void Preamble::handle_package(Parser &p, string const & name,
                                h_font_sans[0] = "IBMPlexSansLight";
                                continue;
                        }
-                       if (opt == "semibold") {
-                               h_font_sans[0] = "IBMPlexSansSemibold";
-                               continue;
-                       }
                        if (!xopts.empty())
                                xopts += ", ";
                        xopts += opt;
@@ -1353,10 +1345,6 @@ void Preamble::handle_package(Parser &p, string const & name,
                                h_font_typewriter[0] = "IBMPlexMonoLight";
                                continue;
                        }
-                       if (opt == "semibold"){
-                               h_font_typewriter[0] = "IBMPlexMonoSemibold";
-                               continue;
-                       }
                        if (!xopts.empty())
                                xopts += ", ";
                        xopts += opt;