Am Freitag, 10. August 2018 17:12:31 CEST schrieb Jürgen Spitzmüller <sp...@lyx.org>: > Am Freitag, den 10.08.2018, 15:41 +0200 schrieb Kornel Benko: > > Would the following work? And is it OK to not have the conversion > > routine? > > Yes. > > > ############################### > > 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", > > "\\font_typewriter"] > > for ft in font_types: > > i = find_token(document.header, ft, 0) > > if i != -1: > > val = get_value(document.header, ft, i) > > if val in dejavu_fonts: > > preamble = "\\usepackage{%s}" % val > > add_to_preamble(document, [preamble]) > > document.header[i] = > > document.header[i].replace(val, "default") > > Looks good. But don't you want to support the scaled option of the > package? > > > ############################### > > > > Also looking into lyx_2_4.py > > revert = [ > > [558, [revert_timeinfo, revert_namenoextinfo]], > > [558, [revert_dateinfo]], > > ... > > looks wrong (2 times 558). Do I miss something here? > > Fixed. Thanks. >
OK, this version works here Kornel
diff --git a/development/FORMAT b/development/FORMAT index cfd4302..4bf2519 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -5,10 +5,13 @@ Please keep the entries informative enough, i.e. try to indicate what changes happened in particular if possible. A good example would be 2010-01-10 entry. ----------------------- +2018-08-10 Kornel Benko <kor...@lyx.org> + * format incremented to 561: Added DejaVu fonts + 2018-08-07 Jürgen Spitzmüller <sp...@lyx.org> * format incremented to 560: Time-related info insets: time, modtime, fixtime; new buffer info inset type: name-noext. 2018-08-04 Jürgen Spitzmüller <sp...@lyx.org> diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 401406e..ac03ff8 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -443,10 +443,15 @@ \TestPackage{ccfonts} \TestFont[ccr10]{concrete} % required by ccfonts \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} \TestPackage{fourier} \TestPackage{garamondx} diff --git a/lib/latexfonts b/lib/latexfonts index f3a438a..77b080c 100644 --- a/lib/latexfonts +++ b/lib/latexfonts @@ -146,10 +146,22 @@ Font cmr FontEncoding OT1 SwitchDefault 1 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 EndFont @@ -526,10 +538,22 @@ Font cmss Family sf FontEncoding OT1 SwitchDefault 1 EndFont +Font DejaVuSans + GuiName "DejaVu Sans" + Family sf + Package DejaVuSans +EndFont + +Font DejaVuSansCondensed + GuiName "DejaVu Sans Condensed" + Family sf + Package DejaVuSansCondensed +EndFont + Font helvet GuiName "Helvetica" Family sf ScaleOption scaled=$$val Package helvet @@ -631,11 +655,10 @@ Font uop Family sf SwitchDefault 1 Requires urwclassico EndFont - # # MONOSPACED FONTS # Font beramono @@ -665,10 +688,16 @@ Font courier Family tt Package courier Requires psnfss EndFont +Font DejaVuSansMono + GuiName "DejaVu Sans Mono" + Family tt + Package DejaVuSansMono +EndFont + Font libertine-mono GuiName "Libertine Mono" Family tt ScaleOption scaled=$$val Package libertineMono diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index 4d8e3da..c8e5811 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -49,10 +49,42 @@ from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble) ### ### Conversion and reversion routines ### ############################################################################### +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"] + sfval = get_value(document.header, "\\font_sf_scale", 0) + # cutoff " 100" + sfval = sfval[:-4] + if sfval != "100": + sfoption = "scaled=" + format(float(sfval) / 100, '.2f') + 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: + preamble = "\\usepackage{%s}" % val + add_to_preamble(document, [preamble]) + 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') + add_to_preamble(document, ["\\usepackage[" + xoption + "]{" + val + "}"]) + def removeFrontMatterStyles(document): " Remove styles Begin/EndFromatter" layouts = ['BeginFrontmatter', 'EndFrontmatter'] for layout in layouts: @@ -1069,14 +1101,16 @@ convert = [ [555, []], [556, []], [557, [convert_vcsinfo]], [558, [removeFrontMatterStyles]], [559, []], - [560, []] + [560, []], + [561, []] ] revert = [ + [560, [revert_dejavu]], [559, [revert_timeinfo, revert_namenoextinfo]], [558, [revert_dateinfo]], [557, [addFrontMatterStyles]], [556, [revert_vcsinfo]], [555, [revert_bibencoding]], diff --git a/src/version.h b/src/version.h index f408633..f583da6 100644 --- a/src/version.h +++ b/src/version.h @@ -30,12 +30,12 @@ extern char const * const lyx_package; /// This is the version information shown by 'lyx -version' 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 #warning "tex2lyx produces an out of date file format." #warning "Please update tex2lyx as soon as possible, since it depends implicitly"
signature.asc
Description: This is a digitally signed message part.