From 850c5a3d5545eb6cf76e3c94d1e534c3b74a86bd Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 18 Jul 2019 10:50:46 +0200 Subject: [PATCH] Support for CrimsonPro --- development/FORMAT | 3 +- lib/chkconfig.ltx | 1 + lib/doc/LaTeXConfig.lyx | 84 ++++++++++++++++++++++++++++++++++++++++ lib/latexfonts | 44 +++++++++++++++++++++ lib/lyx2lyx/lyx_2_4.py | 24 +++++++++++- src/tex2lyx/Preamble.cpp | 39 +++++++++++++++++-- 6 files changed, 188 insertions(+), 7 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 6ea3d4ba61..61f990e4db 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -8,7 +8,8 @@ changes happened in particular if possible. A good example would be ----------------------- 2019-07-17 Kornel Benko - * format incremented to 583: Support for the Chivo font family. + Jürgen Spitzmüller + * format incremented to 583: Support for the Chivo and CrimsonPro font families. 2019-07-15 Kornel Benko Jürgen Spitzmüller diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 19256a3681..dd015bda8e 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -460,6 +460,7 @@ \TestPackage{cochineal} \TestPackage{courier} \TestPackage{crimson} +\TestPackage{CrimsonPro} \TestPackage{helvet} \TestPackage{mathpazo} \TestPackage{mathpple} diff --git a/lib/doc/LaTeXConfig.lyx b/lib/doc/LaTeXConfig.lyx index 69c65abcb6..dd6c02e475 100644 --- a/lib/doc/LaTeXConfig.lyx +++ b/lib/doc/LaTeXConfig.lyx @@ -503,6 +503,46 @@ Notes: CM bright is a sans serif font that also provides nice sans serif math fonts. \end_layout +\begin_layout Subsection + +\change_inserted -712698321 1563439314 +Cochineal +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1563439310 +Found: +\begin_inset Info +type "package" +arg "cochineal" +\end_inset + + +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1563439356 +CTAN: +\family sans +fonts/cochineal +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1563439409 +Notes: The +\family sans +cochineal +\family default + package provides support for the +\emph on +Crimson +\emph default + serif font. +\end_layout + \begin_layout Subsection Concrete \end_layout @@ -538,6 +578,50 @@ Concrete Mathematics concrete \emph default fonts. +\change_inserted -712698321 1563439208 + +\end_layout + +\begin_layout Subsection + +\change_inserted -712698321 1563439214 +CrimsonPro +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1563439209 +Found: +\begin_inset Info +type "package" +arg "CrimsonPro" +\end_inset + + +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1563439244 +CTAN: +\family sans +fonts/crimsonpro +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1563439296 +Notes: The +\family sans +CrimsonPro +\family default + package provides support for the +\emph on +CrimsonPro +\emph default + serif font, an enhanced redesign of Crimson (Cochineal). +\change_unchanged + \end_layout \begin_layout Subsection diff --git a/lib/latexfonts b/lib/latexfonts index cbfb0d25cc..11dfc5e659 100644 --- a/lib/latexfonts +++ b/lib/latexfonts @@ -154,6 +154,50 @@ Font cmr OsfFont eco EndFont +Font CrimsonPro + GuiName "Crimson Pro" + Family rm + OsfOption lf + OsfDefault 1 + Package CrimsonPro + AltFonts crimson + MoreOptions 1 + FontEncoding OT1,T1,LY1,TS1 +EndFont + +Font CrimsonProMedium + GuiName "Crimson Pro (Medium)" + Family rm + OsfOption lf + OsfDefault 1 + Package CrimsonPro + PackageOptions medium + MoreOptions 1 + FontEncoding OT1,T1,LY1,TS1 +EndFont + +Font CrimsonProLight + GuiName "Crimson Pro (Light)" + Family rm + OsfOption lf + OsfDefault 1 + Package CrimsonPro + PackageOptions light + MoreOptions 1 + FontEncoding OT1,T1,LY1,TS1 +EndFont + +Font CrimsonProExtraLight + GuiName "Crimson Pro (Extralight)" + Family rm + OsfOption lf + OsfDefault 1 + Package CrimsonPro + PackageOptions extralight + MoreOptions 1 + FontEncoding OT1,T1,LY1,TS1 +EndFont + Font DejaVuSerif GuiName "DejaVu Serif" Family rm diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index 4f2fcf7280..e7962c64b4 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -183,6 +183,10 @@ def createFontMapping(fontlist): fm.expandFontMapping(['ChivoThin,thin', 'ChivoLight,light', 'Chivo,regular', 'ChivoMedium,medium'], "sans", "sf", "Chivo", "scale", "oldstyle") + elif font == 'CrimsonPro': + fm.expandFontMapping(['CrimsonPro', 'CrimsonProExtraLight,extralight', 'CrimsonProLight,light', + 'CrimsonProMedium,medium'], + "roman", None, "CrimsonPro", None, "lf", "true") elif font == 'Fira': fm.expandFontMapping(['FiraSans', 'FiraSansBook,book', 'FiraSansThin,thin', 'FiraSansLight,light', @@ -3082,6 +3086,22 @@ def convert_NotoRegulars(document): document.header[i] = " ".join(ttfont) +def convert_CrimsonProFont(document): + " Handle CrimsonPro font definition to LaTeX " + + if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: + fm = createFontMapping(['CrimsonPro']) + convert_fonts(document, fm, "lf") + +def revert_CrimsonProFont(document): + " Revert native CrimsonPro font definition to LaTeX " + + if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: + fontmap = dict() + fm = createFontMapping(['CrimsonPro']) + if revert_fonts(document, fm, fontmap, False, True): + add_preamble_fonts(document, fontmap) + ## # Conversion hub # @@ -3126,10 +3146,10 @@ 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,convert_NotoRegulars]], + [583, [convert_ChivoFont,convert_Semibolds,convert_NotoRegulars,convert_CrimsonProFont]], ] -revert = [[582, [revert_ChivoFont]], +revert = [[582, [revert_ChivoFont,revert_CrimsonProFont]], [581, [revert_CantarellFont,revert_FiraFont]], [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! diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index ebcb2e6588..56cd7903c7 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -142,10 +142,10 @@ const char * const known_old_language_packages[] = {"french", "frenchle", char const * const known_fontsizes[] = { "10pt", "11pt", "12pt", 0 }; const char * const known_roman_font_packages[] = { "ae", "beraserif", "bookman", -"ccfonts", "chancery", "charter", "cmr", "cochineal", "crimson", "DejaVuSerif", "DejaVuSerifCondensed", "fourier", -"garamondx", "libertine", "libertineRoman", "libertine-type1", "lmodern", "mathdesign", "mathpazo", -"mathptmx", "MinionPro", "newcent", "noto", "noto-serif", "PTSerif", "tgbonum", "tgchorus", -"tgpagella", "tgschola", "tgtermes", "utopia", "xcharter", 0 }; +"ccfonts", "chancery", "charter", "cmr", "cochineal", "crimson", "CrimsonPro", "DejaVuSerif", +"DejaVuSerifCondensed", "fourier", "garamondx", "libertine", "libertineRoman", "libertine-type1", +"lmodern", "mathdesign", "mathpazo", "mathptmx", "MinionPro", "newcent", "noto", "noto-serif", +"PTSerif", "tgbonum", "tgchorus", "tgpagella", "tgschola", "tgtermes", "utopia", "xcharter", 0 }; const char * const known_sans_font_packages[] = { "avant", "berasans", "biolinum", "biolinum-type1", "cantarell", "Chivo", "cmbr", "cmss", "DejaVuSans", "DejaVuSansCondensed", "FiraSans", "helvet", "iwona", @@ -947,6 +947,37 @@ void Preamble::handle_package(Parser &p, string const & name, options.clear(); } + if (name == "CrimsonPro") { + h_font_roman_osf = "true"; + for (auto const & opt : allopts) { + if (opt == "lf" || opt == "lining") { + h_font_roman_osf = "false"; + continue; + } + if (opt == "proportional" || opt == "p") + continue; + if (opt == "medium") { + h_font_roman[0] = "CrimsonProMedium"; + continue; + } + if (opt == "extralight") { + h_font_roman[0] = "CrimsonProExtraLight"; + continue; + } + if (opt == "light") { + h_font_roman[0] = "CrimsonProLight"; + continue; + } + if (!xopts.empty()) + xopts += ", "; + xopts += opt; + } + if (!xopts.empty()) + h_font_roman_opts = xopts; + options.clear(); + } + + if (name == "eco") // font uses old-style figure h_font_roman_osf = "true"; -- 2.39.2