diff --git a/lib/latexfonts b/lib/latexfonts index 33ae9da299..9b75744b68 100644 --- a/lib/latexfonts +++ b/lib/latexfonts @@ -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 diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index d7831dc5b6..61066ab8cc 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -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]], diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index ea76e5f8c5..2ab24e11c1 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -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;