From 366e37c851ab05c08ee492fed22954eb3028b21c Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Fri, 10 Aug 2018 19:38:06 +0200 Subject: [PATCH] Added latex-DejaVu fonts to lyx-GUI. Increment lyx-format to 561 --- development/FORMAT | 3 +++ lib/chkconfig.ltx | 5 +++++ lib/latexfonts | 34 +++++++++++++++++++++++++++++++++- lib/lyx2lyx/lyx_2_4.py | 31 ++++++++++++++++++++++++++++++- src/tex2lyx/Preamble.cpp | 6 +++--- src/tex2lyx/TODO.txt | 1 + src/version.h | 4 ++-- 7 files changed, 77 insertions(+), 7 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index cfd4302eb4..4bf2519331 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -7,6 +7,9 @@ changes happened in particular if possible. A good example would be ----------------------- +2018-08-10 Kornel Benko + * format incremented to 561: Added DejaVu fonts + 2018-08-07 Jürgen Spitzmüller * format incremented to 560: Time-related info insets: time, modtime, fixtime; new buffer info inset type: name-noext. diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 401406eb64..ac03ff8b2f 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -445,6 +445,11 @@ \TestFont[eorm10]{ecc} % required by ccfonts \TestPackage[ot1ccr.fd]{concmath} % required by ccfonts \TestPackage{cmbright} +\TestPackage{DejaVuSans} +\TestPackage{DejaVuSansCondensed} +\TestPackage{DejaVuSansMono} +\TestPackage{DejaVuSerif} +\TestPackage{DejaVuSerifCondensed} \TestPackage{eco} \TestPackage{eulervm} \TestPackage{feyn} diff --git a/lib/latexfonts b/lib/latexfonts index f3a438a557..2c9c246aa1 100644 --- a/lib/latexfonts +++ b/lib/latexfonts @@ -148,6 +148,18 @@ Font cmr OsfFont eco EndFont +Font DejaVuSerif + GuiName "DejaVu Serif" + Family rm + Package DejaVuSerif +EndFont + +Font DejaVuSerifCondensed + GuiName "DejaVu Serif Condensed" + Family rm + Package DejaVuSerifCondensed +EndFont + AltFont eco Family rm Package eco @@ -528,6 +540,20 @@ Font cmss SwitchDefault 1 EndFont +Font DejaVuSans + GuiName "DejaVu Sans" + Family sf + Package DejaVuSans + ScaleOption scaled=$$val +EndFont + +Font DejaVuSansCondensed + GuiName "DejaVu Sans Condensed" + Family sf + Package DejaVuSansCondensed + ScaleOption scaled=$$val +EndFont + Font helvet GuiName "Helvetica" Family sf @@ -633,7 +659,6 @@ Font uop Requires urwclassico EndFont - # # MONOSPACED FONTS # @@ -667,6 +692,13 @@ Font courier Requires psnfss EndFont +Font DejaVuSansMono + GuiName "DejaVu Sans Mono" + Family tt + Package DejaVuSansMono + ScaleOption scaled=$$val +EndFont + Font libertine-mono GuiName "Libertine Mono" Family tt diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index 4d8e3da977..b5c325f4cb 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -51,6 +51,33 @@ from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble) ### ############################################################################### +def revert_dejavu(document): + " Revert native DejaVu font definition to LaTeX " + + if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: + dejavu_fonts = ['DejaVuSerif', 'DejaVuSerifCondensed', 'DejaVuSans', + 'DejaVuSansMono', 'DejaVuSansCondensed'] + font_types = ["\\font_roman", "\\font_sans,sf", "\\font_typewriter,tt"] + for ft1 in font_types: + fts = ft1.split(",") + ft = fts[0] + i = find_token(document.header, ft, 0) + if i != -1: + val = get_value(document.header, ft, i) + words = val.split() + val = words[0].replace('"', '') + if val in dejavu_fonts: + xoption = "" + document.header[i] = ft + ' "default" ' + words[1] + if len(fts) > 1: + xval = get_value(document.header, "\\font_" + fts[1] + "_scale", 0) + # cutoff " 100" + xval = xval[:-4] + if xval != "100": + xoption = "[scaled=" + format(float(xval) / 100, '.2f') + "]" + preamble = "\\usepackage" + xoption + "{%s}" % val + add_to_preamble(document, [preamble]) + def removeFrontMatterStyles(document): " Remove styles Begin/EndFromatter" @@ -1071,10 +1098,12 @@ convert = [ [557, [convert_vcsinfo]], [558, [removeFrontMatterStyles]], [559, []], - [560, []] + [560, []], + [561, []] ] revert = [ + [560, [revert_dejavu]], [559, [revert_timeinfo, revert_namenoextinfo]], [558, [revert_dateinfo]], [557, [addFrontMatterStyles]], diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index e4e10c088e..4dc042fbac 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -141,18 +141,18 @@ const char * const known_old_language_packages[] = {"french", "frenchle", char const * const known_fontsizes[] = { "10pt", "11pt", "12pt", 0 }; const char * const known_roman_fonts[] = { "ae", "beraserif", "bookman", -"ccfonts", "chancery", "charter", "cmr", "cochineal", "crimson", "fourier", +"ccfonts", "chancery", "charter", "cmr", "cochineal", "crimson", "DejaVuSerif", "DejaVuSerifCondensed", "fourier", "garamondx", "libertine", "libertineRoman", "libertine-type1", "lmodern", "mathdesign", "mathpazo", "mathptmx", "MinionPro", "newcent", "NotoSerif-TLF", "PTSerif-TLF", "tgbonum", "tgchorus", "tgpagella", "tgschola", "tgtermes", "utopia", "xcharter", 0 }; const char * const known_sans_fonts[] = { "avant", "berasans", "biolinum", -"biolinum-type1", "cmbr", "cmss", "helvet", "iwona", "iwonac", "iwonal", "iwonalc", +"biolinum-type1", "cmbr", "cmss", "DejaVuSans", "DejaVuSansCondensed", "helvet", "iwona", "iwonac", "iwonal", "iwonalc", "kurier", "kurierc", "kurierl", "kurierlc", "lmss", "NotoSans-TLF", "PTSans-TLF", "tgadventor", "tgheros", "uop", 0 }; const char * const known_typewriter_fonts[] = { "beramono", "cmtl", "cmtt", -"courier", "lmtt", "luximono", "fourier", "libertineMono", "libertineMono-type1", "lmodern", +"courier", "DejaVuSansMono", "lmtt", "luximono", "fourier", "libertineMono", "libertineMono-type1", "lmodern", "mathpazo", "mathptmx", "newcent", "NotoMono-TLF", "PTMono-TLF", "tgcursor", "txtt", 0 }; const char * const known_math_fonts[] = { "eulervm", "newtxmath", 0}; diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index b2b540644f..8b3ab40ef9 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -63,6 +63,7 @@ Format LaTeX feature LyX feature 556 Bib files encoding \begin_inset CommandInset bibtex Biblatex: bibencoding= [latex name] encoding= [lyx name] BibTeX: \bgroup\inputencoding{}...\egroup +561 DejaVu fonts for latex \font_(roman|sans|typewriter) setting diff --git a/src/version.h b/src/version.h index f4086333f2..f583da6d4e 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 560 // spitz: time info insets -#define LYX_FORMAT_TEX2LYX 560 +#define LYX_FORMAT_LYX 561 // kornel: Added dejavu fonts +#define LYX_FORMAT_TEX2LYX 561 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER -- 2.39.5