From cc1c48188b79b5cf370d1b3c6ead39ab85df6fc2 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 18 Jul 2019 08:41:00 +0200 Subject: [PATCH] Merge the two noto regular fonts These are actually the same font and shape, so no need for two entries --- lib/latexfonts | 94 ++++++++++++++++++------------------------ lib/lyx2lyx/lyx_2_4.py | 41 ++++++++++++++++-- 2 files changed, 78 insertions(+), 57 deletions(-) diff --git a/lib/latexfonts b/lib/latexfonts index a18aa2e9f4..017c45f264 100644 --- a/lib/latexfonts +++ b/lib/latexfonts @@ -370,65 +370,58 @@ Font newcent EndFont Font NotoSerifRegular - GuiName "Noto Serif" - Family rm - Package noto-serif - OsfOption osf + GuiName "Noto Serif" + Family rm + Package noto-serif + OsfOption osf + MoreOptions 1 + CompleteFont noto +EndFont + +AltFont noto + GuiName "Noto Serif" + Family rm + Package noto + OsfOption osf MoreOptions 1 EndFont Font NotoSerifMedium - GuiName "Noto Serif (Medium)" - Family rm - Package noto-serif - PackageOptions medium - OsfDefault 0 - OsfOption osf + GuiName "Noto Serif (Medium)" + Family rm + Package noto-serif + PackageOptions medium + OsfDefault 0 + OsfOption osf MoreOptions 1 EndFont Font NotoSerifThin - GuiName "Noto Serif (Thin)" - Family rm - Package noto-serif - PackageOptions thin - OsfDefault 0 - OsfOption osf + GuiName "Noto Serif (Thin)" + Family rm + Package noto-serif + PackageOptions thin + OsfDefault 0 + OsfOption osf MoreOptions 1 EndFont Font NotoSerifLight - GuiName "Noto Serif (Light)" - Family rm - Package noto-serif - PackageOptions light - OsfDefault 0 - OsfOption osf + GuiName "Noto Serif (Light)" + Family rm + Package noto-serif + PackageOptions light + OsfDefault 0 + OsfOption osf MoreOptions 1 EndFont Font NotoSerifExtralight - GuiName "Noto Serif (Extralight)" - Family rm - Package noto-serif - PackageOptions extralight - OsfDefault 0 - OsfOption osf - MoreOptions 1 -EndFont - -Font NotoSerif-TLF - GuiName "Noto Serif" - Family rm - SwitchDefault 1 - Requires noto - CompleteFont noto -EndFont - -AltFont noto - GuiName "Noto Serif" + GuiName "Noto Serif (Extralight)" Family rm - Package noto + Package noto-serif + PackageOptions extralight + OsfDefault 0 OsfOption osf MoreOptions 1 EndFont @@ -917,7 +910,7 @@ Font NotoSansRegular Package noto-sans OsfDefault 0 OsfOption osf - MoreOptions 1 + MoreOptions 1 EndFont Font NotoSansMedium @@ -928,7 +921,7 @@ Font NotoSansMedium PackageOptions medium OsfDefault 0 OsfOption osf - MoreOptions 1 + MoreOptions 1 EndFont Font NotoSansThin @@ -939,7 +932,7 @@ Font NotoSansThin PackageOptions thin OsfDefault 0 OsfOption osf - MoreOptions 1 + MoreOptions 1 EndFont Font NotoSansLight @@ -950,7 +943,7 @@ Font NotoSansLight PackageOptions light OsfDefault 0 OsfOption osf - MoreOptions 1 + MoreOptions 1 EndFont Font NotoSansExtralight @@ -961,14 +954,7 @@ Font NotoSansExtralight PackageOptions extralight OsfDefault 0 OsfOption osf - MoreOptions 1 -EndFont - -Font NotoSans-TLF - GuiName "Noto Sans" - Family sf - SwitchDefault 1 - Requires noto + MoreOptions 1 EndFont Font PTSans-TLF diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index 61066ab8cc..4f2fcf7280 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -2966,8 +2966,6 @@ def convert_Semibolds(document): 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.") @@ -3047,6 +3045,43 @@ def convert_Semibolds(document): document.header[x] = "\\font_typewriter_opts \"semibold, " + sfopts[1].strip('"') + "\"" +def convert_NotoRegulars(document): + " Merge diverse noto reagular fonts " + + 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 == "NotoSerif-TLF": + romanfont[1] = '"NotoSerifRegular"' + document.header[i] = " ".join(romanfont) + + 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 == "NotoSans-TLF": + sffont[1] = '"NotoSansRegular"' + document.header[i] = " ".join(sffont) + + 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 == "NotoMono-TLF": + ttfont[1] = '"NotoMonoRegular"' + document.header[i] = " ".join(ttfont) + + ## # Conversion hub # @@ -3091,7 +3126,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,convert_Semibolds]], + [583, [convert_ChivoFont,convert_Semibolds,convert_NotoRegulars]], ] revert = [[582, [revert_ChivoFont]], -- 2.39.5