diff options
71 files changed, 753 insertions, 772 deletions
diff --git a/context/data/scite/context/scite-context.properties b/context/data/scite/context/scite-context.properties index 8db638e60..a092aa1db 100644 --- a/context/data/scite/context/scite-context.properties +++ b/context/data/scite/context/scite-context.properties @@ -68,6 +68,13 @@ file.patterns.context=*.tex;*.mkii;*.mkiv;*.mkvi;*.mkix;*.mkxi;*.mkxl;*.mklx; open.suffix.$(file.patterns.context)=.tex +# ConTeXt: suffixes (really needed) + +file.patterns.metapost= +file.patterns.metafun=*.mp;*.mpii;*.mpiv;*.mpxl; + +open.suffix.$(file.patterns.metafun)=.mp + #~ api.$(file.patterns.context)=$(SciteDefaultHome)/context/scite-context.api # starttext diff --git a/doc/context/scripts/mkiv/mtx-pdf.html b/doc/context/scripts/mkiv/mtx-pdf.html deleted file mode 100644 index 2932b942c..000000000 --- a/doc/context/scripts/mkiv/mtx-pdf.html +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - -<!-- compare with lmx framework variant --> - -<!-- - filename : context-base.xml - comment : companion to mtx-server-ctx-startup.tex - author : Hans Hagen, PRAGMA-ADE, Hasselt NL - copyright: PRAGMA ADE / ConTeXt Development Team - license : see context related readme files ---> - -<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> - <head> - <title>ConTeXt PDF Helpers 0.10</title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> - <style type="text/css"> - body { color: #FFFFFF; background-color: #808080; font-family: optima, verdana, futura, "lucida sans", arial, geneva, helvetica, sans; font-size: 12px; line-height: 18px; } a:link, a:active, a:visited { color: #FFFFFF; } a.dir-view:link, a.dir-view:active, a.dir-view:visited { color: #FFFFFF; text-decoration: underline; } .valid { color: #00FF00; } .invalid { color: #FF0000; } .invisible { visibility: hidden; } button, .commonlink, .smallbutton { font-weight: bold; font-size: 12px; text-decoration: none; color: #000000; border-color: #7F7F7F; border-style: solid; border-width: .125ex; background-color: #FFFFFF; padding: .5ex; } .smallbutton { width: 1em; } a.commonlink:link, a.commonlink:active, a.commonlink:visited, a.smalllink:link, a.smalllink:active, a.smalllink:visited { font-weight: bold; font-size: 12px; text-decoration: none; color: #000000; } h1, .title { font-style: normal; font-weight: normal; font-size: 18px; line-height: 18px; margin-bottom: 20px; } h2, .subtitle { font-style: normal; font-weight: normal; font-size: 12px; margin-top: 18px; margin-bottom: 18px; } table { line-height: 18px; font-size: 12px; margin: 0; } th { font-weight: bold; text-align: left; padding-bottom: 6px; } .tc { font-weight: bold; text-align: left; } p, li { max-width: 60em; } .empty-line { margin-top: 4px; } .more-room { margin-right: 1.5em; } .much-more-room { margin-right: 3em; } #main { position: absolute; left: 10%; top: 10%; right: 10%; bottom: 10%; z-index: 2; width: 80%; height: 80%; padding: 0%; margin: 0%; overflow: auto; border-style: none; border-width: 0; background-color: #3F3F3F; } #main-settings { margin: 12px; x_max-width: 60em; line-height: 18px; font-size: 12px; } #left { position: absolute; top : 10%; left: 0%; bottom: 0%; right: 90%; z-index: 1; width: 10%; height: 90%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #4F6F6F; } #right { position: absolute; top : 0%; left: 90%; bottom: 10%; right: 0%; z-index: 1; width: 10%; height: 90%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #4F6F6F; _margin-left: -15px; } #bottom { position: absolute; left: 10%; right: 0%; top: 90%; bottom: 0%; z-index: 1; width: 90%; height: 10%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #6F6F8F; } #top { position: absolute; left: 0%; right: 10%; top: 0%; bottom: 90%; z-index: 1; width: 90%; height: 10%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #6F6F8F; } #top-one { position: absolute; bottom: 50%; width: 100%; buggedheight: 100%; } #top-two { position: relative; margin-bottom: -9px; margin-left: 12px; margin-right: 12px; line-height: 18px; text-align: right; vertical-align: middle; } #bottom-one { position: absolute; bottom: 50%; width: 100%; buggedheight: 100%; } #bottom-two { position: relative; margin-bottom: -9px; margin-left: 12px; margin-right: 12px; line-height: 18px; text-align: left; vertical-align: middle; } #left-one { position: absolute; width: 100%; buggedheight: 100%; } #left-two { position: relative; margin-top: 12px; line-height: 18px; text-align: center; vertical-align: top; } #right-one { display: table; height: 100%; width: 100%; } #right-two { display: table-row; height: 100%; width: 100%; } #right-three { display: table-cell; width: 100%; vertical-align: bottom; _position: absolute; _top: 100%; } #right-four { text-align: center; margin-bottom: 2ex; _position: relative; _top: -100%; } #more-top { position: absolute; top: 0%; left: 90%; bottom: 90%; right: 0%; z-index: 3; width: 10%; height: 10%; padding: 0%; margin: 0%; border-style: none; border-width: 0; } #more-top-settings { text-align: center; } #more-right-settings { margin-right: 12px; margin-left: 12px; line-height: 18px; font-size: 10px; text-align: center; } #right-safari { _display: table; width: 100%; height: 100%; } - </style> - <style type="text/css"> - </style> - </head> - <body> - <div id="top"> <div id="top-one"> - <div id="top-two">ConTeXt PDF Helpers 0.10 </div> - </div> - </div> - <div id="bottom"> <div id="bottom-one"> - <div id="bottom-two">wiki: http://contextgarden.net | mail: ntg-context@ntg.nl | website: http://www.pragma-ade.nl</div> - </div> - </div> - <div id="left"></div> - <div id="right"></div> - <div id="main"> - <div id='main-settings'> - <h1>Command line options</h1> -<table> - <tr><th style="width: 10em">flag</th><th style="width: 8em">value</th><th>description</th></tr> - <tr><th/><td/><td/></tr> - <tr><th>--info</th><td></td><td>show some info about the given file</td></tr> - <tr><th>--metadata</th><td></td><td>show metadata xml blob</td></tr> - <tr><th>--pretty</th><td></td><td>replace newlines in metadata</td></tr> - <tr><th>--fonts</th><td></td><td>show used fonts (--detail)</td></tr> - <tr><th>--object</th><td></td><td>show object"/></td></tr> - <tr><th/><td/><td/></tr> - </table> -<br/> - </div> - </div> - </body> -</html> diff --git a/doc/context/scripts/mkiv/mtx-pdf.man b/doc/context/scripts/mkiv/mtx-pdf.man deleted file mode 100644 index ea74f2aa1..000000000 --- a/doc/context/scripts/mkiv/mtx-pdf.man +++ /dev/null @@ -1,39 +0,0 @@ -.TH "mtx-pdf" "1" "01-01-2021" "version 0.10" "ConTeXt PDF Helpers" -.SH NAME - mtx-pdf - ConTeXt PDF Helpers -.SH SYNOPSIS -.B mtxrun --script pdf [ -.I OPTIONS ... -.B ] [ -.I FILENAMES -.B ] -.SH DESCRIPTION -.B ConTeXt PDF Helpers -.SH OPTIONS -.TP -.B --info -show some info about the given file -.TP -.B --metadata -show metadata xml blob -.TP -.B --pretty -replace newlines in metadata -.TP -.B --fonts -show used fonts (--detail) -.TP -.B --object -show object"/> -.SH AUTHOR -More information about ConTeXt and the tools that come with it can be found at: - - -.B "maillist:" -ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context - -.B "webpage:" -http://www.pragma-ade.nl / http://tex.aanhet.net - -.B "wiki:" -http://contextgarden.net diff --git a/doc/context/scripts/mkiv/mtx-pdf.xml b/doc/context/scripts/mkiv/mtx-pdf.xml deleted file mode 100644 index 08b04d85e..000000000 --- a/doc/context/scripts/mkiv/mtx-pdf.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0"?> -<application> - <metadata> - <entry name="name">mtx-pdf</entry> - <entry name="detail">ConTeXt PDF Helpers</entry> - <entry name="version">0.10</entry> - </metadata> - <flags> - <category name="basic"> - <subcategory> - <flag name="info"><short>show some info about the given file</short></flag> - <flag name="metadata"><short>show metadata xml blob</short></flag> - <flag name="pretty"><short>replace newlines in metadata</short></flag> - <flag name="fonts"><short>show used fonts (<ref name="detail)"/></short></flag> - <flag name="object"><short>show object"/></short></flag> - </subcategory> - <subcategory> - <example><command>mtxrun --script pdf --info foo.pdf</command></example> - <example><command>mtxrun --script pdf --metadata foo.pdf</command></example> - <example><command>mtxrun --script pdf --metadata --pretty foo.pdf</command></example> - <example><command>mtxrun --script pdf --stream=4 foo.pdf</command></example> - </subcategory> - </category> - </flags> -</application> diff --git a/metapost/context/base/mpxl/mp-lmtx.mpxl b/metapost/context/base/mpxl/mp-lmtx.mpxl index 3bbbd6814..4bd5950c1 100644 --- a/metapost/context/base/mpxl/mp-lmtx.mpxl +++ b/metapost/context/base/mpxl/mp-lmtx.mpxl @@ -2269,7 +2269,9 @@ permanent registercomposeglyph, composeglyph ; % Again an experiment (todo: the faster method): -newscriptindex mfid_remaptext ; mfid_remaptext := scriptindex "remaptext" ; def lmt_remaptext = runscript mfid_remaptext enddef ; +% watch the ; that we scan! + +newscriptindex mfid_remaptext ; mfid_remaptext := scriptindex "remaptext" ; def lmt_remaptext = runscript mfid_remaptext ; enddef ; triplet mfun_tt_s ; diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index a550984d2..8c09daa83 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2021.10.15 13:57} +\newcontextversion{2021.10.18 23:11} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 6eaebb20d..1d1d61d0b 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2021.10.15 13:57} +\edef\contextversion{2021.10.18 23:11} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-en.mkii b/tex/context/base/mkii/mult-en.mkii index 5af7737d1..f990c83e5 100644 --- a/tex/context/base/mkii/mult-en.mkii +++ b/tex/context/base/mkii/mult-en.mkii @@ -79,6 +79,7 @@ \setinterfacevariable{anchor}{anchor} \setinterfacevariable{and}{and} \setinterfacevariable{answerarea}{answerarea} +\setinterfacevariable{append}{append} \setinterfacevariable{appendices}{appendices} \setinterfacevariable{appendix}{appendix} \setinterfacevariable{april}{april} @@ -150,6 +151,7 @@ \setinterfacevariable{commands}{commands} \setinterfacevariable{comment}{comment} \setinterfacevariable{component}{component} +\setinterfacevariable{compress}{compress} \setinterfacevariable{compressseparator}{compressseparator} \setinterfacevariable{compressstopper}{compressstopper} \setinterfacevariable{concept}{concept} @@ -186,6 +188,7 @@ \setinterfacevariable{enumeration}{enumeration} \setinterfacevariable{environment}{environment} \setinterfacevariable{even}{even} +\setinterfacevariable{explicit}{explicit} \setinterfacevariable{export}{export} \setinterfacevariable{external}{external} \setinterfacevariable{extremestretch}{extremestretch} @@ -436,6 +439,7 @@ \setinterfacevariable{postscript}{postscript} \setinterfacevariable{precedingpage}{precedingpage} \setinterfacevariable{preference}{preference} +\setinterfacevariable{prepend}{prepend} \setinterfacevariable{preview}{preview} \setinterfacevariable{previous}{previous} \setinterfacevariable{previousevenpage}{previousevenpage} @@ -1367,6 +1371,7 @@ \setinterfaceelement{load}{load} \setinterfaceelement{local}{local} \setinterfaceelement{makeup}{makeup} +\setinterfaceelement{namednotation}{namednotation} \setinterfaceelement{namedtyping}{namedtyping} \setinterfaceelement{next}{next} \setinterfaceelement{place}{place} @@ -1536,6 +1541,7 @@ \setinterfacecommand{definereferencelist}{definereferencelist} \setinterfacecommand{defineregister}{defineregister} \setinterfacecommand{definerule}{definerule} +\setinterfacecommand{definesavebuffer}{startsavebuffer} \setinterfacecommand{definesection}{definesection} \setinterfacecommand{definesectionblock}{definesectionblock} \setinterfacecommand{definesorting}{definesorting} @@ -1712,6 +1718,9 @@ \setinterfacecommand{moveformula}{moveformula} \setinterfacecommand{moveongrid}{moveongrid} \setinterfacecommand{movesidefloat}{movesidefloat} +\setinterfacecommand{namedconstruction}{namedconstruction} +\setinterfacecommand{nameddescription}{nameddescription} +\setinterfacecommand{namedenumeration}{namedenumeration} \setinterfacecommand{navigating}{navigating} \setinterfacecommand{nodimension}{nodimension} \setinterfacecommand{noheaderandfooterlines}{noheaderandfooterlines} @@ -2083,6 +2092,13 @@ \setinterfacecommand{startmakeup}{startmakeup} \setinterfacecommand{startmarginblock}{startmarginblock} \setinterfacecommand{startmarginrule}{startmarginrule} +\setinterfacecommand{startnamedconstruction}{startnamedconstruction} +\setinterfacecommand{startnameddescription}{startnameddescription} +\setinterfacecommand{startnamedenumeration}{startnamedenumeration} +\setinterfacecommand{startnamedmatrix}{startnamedmatrix} +\setinterfacecommand{startnamedsection}{startnamedsection} +\setinterfacecommand{startnamedsubformulas}{startnamedsubformulas} +\setinterfacecommand{startnamedtyping}{startnamedtyping} \setinterfacecommand{startnarrower}{startnarrower} \setinterfacecommand{startopposite}{startopposite} \setinterfacecommand{startoverlay}{startoverlay} @@ -2126,6 +2142,13 @@ \setinterfacecommand{stopmakeup}{stopmakeup} \setinterfacecommand{stopmarginblock}{stopmarginblock} \setinterfacecommand{stopmarginrule}{stopmarginrule} +\setinterfacecommand{stopnamedconstruction}{stopnamedconstruction} +\setinterfacecommand{stopnameddescription}{stopnameddescription} +\setinterfacecommand{stopnamedenumeration}{stopnamedenumeration} +\setinterfacecommand{stopnamedmatrix}{stopnamedmatrix} +\setinterfacecommand{stopnamedsection}{stopnamedsection} +\setinterfacecommand{stopnamedsubformulas}{stopnamedsubformulas} +\setinterfacecommand{stopnamedtyping}{stopnamedtyping} \setinterfacecommand{stopnarrower}{stopnarrower} \setinterfacecommand{stopopposite}{stopopposite} \setinterfacecommand{stopoverlay}{stopoverlay} diff --git a/tex/context/base/mkii/mult-fr.mkii b/tex/context/base/mkii/mult-fr.mkii index 369931ac8..6abaaec24 100644 --- a/tex/context/base/mkii/mult-fr.mkii +++ b/tex/context/base/mkii/mult-fr.mkii @@ -188,6 +188,7 @@ \setinterfacevariable{enumeration}{énumération} \setinterfacevariable{environment}{environnement} \setinterfacevariable{even}{paire} +\setinterfacevariable{explicit}{explicit} \setinterfacevariable{export}{exporter} \setinterfacevariable{external}{externe} \setinterfacevariable{extremestretch}{etirementextreme} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index c97e9b74b..4fd44d874 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.10.15 13:57} +\newcontextversion{2021.10.18 23:11} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 24aa443d2..80678ac75 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -11,6 +11,10 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +%D There is some residual code in \MKIV\ that results from the transition to \LMTX\ +%D but removeing it can have side effects due to oversights. There is no impact on +%D performance to I leave at that. + % Here is some timing (2015-04-01) luajittex format generation: % % 2.6 sec : normal make @@ -45,7 +49,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2021.10.15 13:57} +\edef\contextversion{2021.10.18 23:11} %D Kind of special: diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 6bcf6b371..1fc58def7 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex aaba8ae4f..7fb96ed2c 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkxl/attr-col.lmt b/tex/context/base/mkxl/attr-col.lmt index 9c542a942..bda57595c 100644 --- a/tex/context/base/mkxl/attr-col.lmt +++ b/tex/context/base/mkxl/attr-col.lmt @@ -48,7 +48,6 @@ local report_transparencies = logs.reporter("transparencies","support") local states = attributes.states local nodeinjections = backends.nodeinjections -local registrations = backends.registrations local unsetvalue = attributes.unsetvalue local enableaction = nodes.tasks.enableaction @@ -348,10 +347,18 @@ function colors.spot(parent,f,d,p) return { 5, .5, .5, .5, .5, 0, 0, 0, .5, parent, f, d, p } end -local function graycolor(...) graycolor = nodeinjections.graycolor return graycolor(...) end -local function rgbcolor (...) rgbcolor = nodeinjections.rgbcolor return rgbcolor (...) end -local function cmykcolor(...) cmykcolor = nodeinjections.cmykcolor return cmykcolor(...) end -local function spotcolor(...) spotcolor = nodeinjections.spotcolor return spotcolor(...) end +local graycolor = nodeinjections.graycolor +local rgbcolor = nodeinjections.rgbcolor +local cmykcolor = nodeinjections.cmykcolor +local spotcolor = nodeinjections.spotcolor + +updaters.register("backends.injections.latebindings",function() + local nodeinjections = backends.nodeinjections + graycolor = nodeinjections.graycolor + rgbcolor = nodeinjections.rgbcolor + cmykcolor = nodeinjections.cmykcolor + spotcolor = nodeinjections.spotcolor +end) local function extender(colors,key) if colors.supported and key == "none" then @@ -513,15 +520,14 @@ local f_transparency = formatters["%s:%s"] registerstorage("attributes/transparencies/registered", registered, "attributes.transparencies.registered") registerstorage("attributes/transparencies/values", values, "attributes.transparencies.values") -local function inject_transparency(...) - inject_transparency = nodeinjections.transparency - return inject_transparency(...) -end +local register_transparency = nodeinjections.registertransparency +local inject_transparency = nodeinjections.injecttransparency -local function register_transparency(...) - register_transparency = registrations.transparency - return register_transparency(...) -end +updaters.register("backends.injections.latebindings",function() + local nodeinjections = backends.nodeinjections + register_transparency = nodeinjections.registertransparency + inject_transparency = nodeinjections.injecttransparency +end) function transparencies.register(name,a,t,force) -- name is irrelevant here (can even be nil) -- Force needed here for metapost converter. We could always force @@ -614,7 +620,17 @@ colorintents.registered = allocate { knockout = 2, } -local data, registered = colorintents.data, colorintents.registered +local inject_overprint = nodeinjections.injectoverprint +local inject_knockout = nodeinjections.injectknockout + +updaters.register("backends.injections.latebindings",function() + local nodeinjections = backends.nodeinjections + inject_overprint = nodeinjections.injectoverprint + inject_knockout = nodeinjections.injectknockout +end) + +local data = colorintents.data +local registered = colorintents.registered local function extender(colorintents,key) if key == "none" then @@ -626,11 +642,11 @@ end local function reviver(data,n) if n == 1 then - local d = nodeinjections.overprint() -- called once + local d = inject_overprint() -- called once data[1] = d return d elseif n == 2 then - local d = nodeinjections.knockout() -- called once + local d = inject_knockout() -- called once data[2] = d return d end diff --git a/tex/context/base/mkxl/back-lua.lmt b/tex/context/base/mkxl/back-imp-lua.lmt index 9204650ea..5bb23973c 100644 --- a/tex/context/base/mkxl/back-lua.lmt +++ b/tex/context/base/mkxl/back-imp-lua.lmt @@ -1,7 +1,7 @@ -if not modules then modules = { } end modules ['back-lua'] = { +if not modules then modules = { } end modules ['back-imp-lua'] = { version = 1.001, optimize = true, - comment = "companion to lpdf-ini.mkiv", + comment = "companion to back-imp-lua.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -93,6 +93,9 @@ end local function prepare(driver) converter = drivers.converters.lmtx + -- if not environment.initex then + backends.initialize("lua") + -- end luatex.registerstopactions(1,function() save() end) @@ -344,6 +347,9 @@ end local function prepare(driver) converter = drivers.converters.lmtx + -- if not environment.initex then + backends.initialize("js") + -- end luatex.registerstopactions(1,function() save() end) diff --git a/tex/context/base/mkxl/back-lua.mkxl b/tex/context/base/mkxl/back-imp-lua.mkxl index 0fb1bcc88..db26657ef 100644 --- a/tex/context/base/mkxl/back-lua.mkxl +++ b/tex/context/base/mkxl/back-imp-lua.mkxl @@ -1,5 +1,5 @@ %D \module -%D [ file=back-lua, +%D [ file=back-imp-lua, %D version=2018.07.26, %D title=\CONTEXT\ Backend Macros, %D subtitle=\LUA, @@ -11,6 +11,6 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\registerctxluafile{back-lua}{autosuffix,optimize} +\registerctxluafile{back-imp-lua}{autosuffix,optimize} \endinput diff --git a/tex/context/base/mkxl/back-mps.lmt b/tex/context/base/mkxl/back-imp-mps.lmt index 2da19ed87..05d7c4a63 100644 --- a/tex/context/base/mkxl/back-mps.lmt +++ b/tex/context/base/mkxl/back-imp-mps.lmt @@ -1,7 +1,7 @@ -if not modules then modules = { } end modules ['back-mps'] = { +if not modules then modules = { } end modules ['back-imp-mps'] = { version = 1.001, optimize = true, - comment = "companion to lpdf-ini.mkiv", + comment = "companion to back-imp-mps.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -79,6 +79,9 @@ end local function prepare(driver) converter = drivers.converters.lmtx + -- if not environment.initex then + backends.initialize("mps") + -- end luatex.registerstopactions(1,function() save() end) diff --git a/tex/context/base/mkxl/back-mps.mkxl b/tex/context/base/mkxl/back-imp-mps.mkxl index d4d428d42..45dde7e36 100644 --- a/tex/context/base/mkxl/back-mps.mkxl +++ b/tex/context/base/mkxl/back-imp-mps.mkxl @@ -1,5 +1,5 @@ %D \module -%D [ file=back-mps, +%D [ file=back-imp-mps, %D version=2018.07.26, %D title=\CONTEXT\ Backend Macros, %D subtitle=\METAPOST, @@ -11,6 +11,6 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\registerctxluafile{back-mps}{autosuffix,optimize} +\registerctxluafile{back-imp-mps}{autosuffix,optimize} \endinput diff --git a/tex/context/base/mkxl/back-imp-pdf.lmt b/tex/context/base/mkxl/back-imp-pdf.lmt new file mode 100644 index 000000000..a57427e66 --- /dev/null +++ b/tex/context/base/mkxl/back-imp-pdf.lmt @@ -0,0 +1,49 @@ +if not modules then modules = { } end modules ['back-imp-pdf'] = { + version = 1.001, + comment = "companion to back-imp-pdf.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- We hide the pdf table from users so that we can guarantee no interference with +-- the way we manage resources, info, etc. Users should use the \type {lpdf} +-- interface instead. For now we have a little for tikz. If really needed some more +-- can be made accessible but it has to happen in a controlled way then, for +-- instance by first loading or enabling some compatibility layer so that we can +-- trace possible interferences. + +updaters.register("backends.pdf.latebindings",function() + -- + local dummy = function() end + local report = logs.reporter("backend") + -- + -- For now we keep this for tikz. If really needed some more can be made + -- accessible but it has to happen in a controlled way then, for instance + -- by first loading or enabling some compatibility layer so that we can + -- trace possible interferences. + -- + pdf = { + immediateobj = lpdf.immediateobject + } + + table.setmetatableindex(pdf,function(t,k) + report("calling unavailable pdf.%s function",k) + t[k] = dummy + return dummy + end) + +end) + +-- The compression setter is defined here because it's probably the only macro +-- that is used independent of a driver being chosen. It's easier this way than +-- checking in other ways unless we add some generic compression setting to +-- all drivers. + +interfaces.implement { + name = "setpdfcompression", + arguments = { "integer", "integer" }, + actions = lpdf.setcompression, +} + +-- The pdf driver itself is installed in lpdf-lmt.lmt! diff --git a/tex/context/base/mkxl/back-pdf.mkxl b/tex/context/base/mkxl/back-imp-pdf.mkxl index d8b5bd6ee..a9cffc6cb 100644 --- a/tex/context/base/mkxl/back-pdf.mkxl +++ b/tex/context/base/mkxl/back-imp-pdf.mkxl @@ -1,5 +1,5 @@ %D \module -%D [ file=back-pdf, +%D [ file=back-imp-pdf, %D version=2009.04.15, %D title=\CONTEXT\ Backend Macros, %D subtitle=\PDF, @@ -24,20 +24,18 @@ \writestatus{loading}{ConTeXt Backend Macros / PDF} +% \registerctxluafile{back-imp-pdf}{autosuffix} % some code will move to lpdf-* + \registerctxluafile{lpdf-ini}{autosuffix} \registerctxluafile{lpdf-lmt}{autosuffix} \registerctxluafile{lpdf-col}{autosuffix} \registerctxluafile{lpdf-xmp}{autosuffix} \registerctxluafile{lpdf-ano}{autosuffix} -\registerctxluafile{lpdf-res}{autosuffix} \registerctxluafile{lpdf-mis}{autosuffix} \registerctxluafile{lpdf-ren}{autosuffix} \registerctxluafile{lpdf-grp}{autosuffix} \registerctxluafile{lpdf-wid}{autosuffix} \registerctxluafile{lpdf-fld}{autosuffix} -%registerctxluafile{lpdf-mov}{autosuffix} -\registerctxluafile{lpdf-u3d}{autosuffix} % this will become a module -%registerctxluafile{lpdf-swf}{} % this will become a module \registerctxluafile{lpdf-tag}{autosuffix} \registerctxluafile{lpdf-fmt}{autosuffix} \registerctxluafile{lpdf-pde}{autosuffix} @@ -47,11 +45,12 @@ \registerctxluafile{lpdf-fnt}{autosuffix} \registerctxluafile{lpdf-rul}{autosuffix} -\registerctxluafile{back-pdp}{autosuffix} -\registerctxluafile{back-pdf}{autosuffix} % some code will move to lpdf-* +\registerctxluafile{back-imp-pdf}{autosuffix} % some code will move to lpdf-* +\registerctxluafile{back-imp-pdp}{autosuffix} + +% \registerctxluafile{lpdf-u3d}{autosuffix} -\loadmkxlfile{back-u3d} % this will become a module -%loadmkxlfile{back-swf} % this will become a module +\loadmkxlfile{back-imp-u3d} \unprotect diff --git a/tex/context/base/mkxl/back-pdp.lmt b/tex/context/base/mkxl/back-imp-pdp.lmt index 5c786d53e..c7acc82a8 100644 --- a/tex/context/base/mkxl/back-pdp.lmt +++ b/tex/context/base/mkxl/back-imp-pdp.lmt @@ -1,6 +1,6 @@ -if not modules then modules = { } end modules ['back-pdp'] = { +if not modules then modules = { } end modules ['back-imp-pdp'] = { version = 1.001, - comment = "companion to lpdf-ini.mkiv", + comment = "companion to back-imp-pdf.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" diff --git a/tex/context/base/mkxl/back-u3d.mkxl b/tex/context/base/mkxl/back-imp-u3d.mkxl index 297dd5545..e91ef485f 100644 --- a/tex/context/base/mkxl/back-u3d.mkxl +++ b/tex/context/base/mkxl/back-imp-u3d.mkxl @@ -1,5 +1,5 @@ %D \module -%D [ file=back-u3d, +%D [ file=back-imp-u3d, %D version=2009.04.15, %D title=\CONTEXT\ Backend Macros, %D subtitle=U3D Experiment, @@ -15,6 +15,8 @@ %D user interface is rather messy an might be improved. The files and setup is %D derived from an example by Michael Vidiassov. +\registerctxluafile{lpdf-u3d}{autosuffix} + \endinput \starttext diff --git a/tex/context/base/mkxl/back-ini.lmt b/tex/context/base/mkxl/back-ini.lmt index 922705742..fc91fb31c 100644 --- a/tex/context/base/mkxl/back-ini.lmt +++ b/tex/context/base/mkxl/back-ini.lmt @@ -53,7 +53,7 @@ local defaults = { tables = tables, } -backends.defaults = defaults +backends.defaults = defaults -- so, when not in the specific namespace we need to register here (to be checked) backends.nodeinjections = { } setmetatableindex(backends.nodeinjections, nodeinjections) backends.codeinjections = { } setmetatableindex(backends.codeinjections, codeinjections) @@ -62,24 +62,42 @@ backends.tables = { } setmetatableindex(backends.tables, tables backends.current = "unknown" -function backends.install(what) +local registered = table.setmetatableindex(function(t,k) + local v = { + name = k, + nodeinjections = { }, + codeinjections = { }, + registrations = { }, + tables = { }, + } + t[k] = v + return v +end) + +backends.registered = registered + +-- The binding feature is mostly there to prevent side effects of overloading +-- not so much for performance because there are not that many calls. + +function backends.initialize(what) if type(what) == "string" then - local backend = backends[what] + local backend = registered[what] if backend then if trace then - if backend.comment then - report("initializing backend %a, %a",what,backend.comment) - else - report("initializing backend %a",what) - end + report("initializing backend %a",what) end - backends.current = what for category, default in next, defaults do local target = backends[category] local plugin = backend [category] setmetatableindex(plugin, default) setmetatableindex(target, plugin) end + -- + backends.current = what + -- delayed / out-of-order locals: like lpdf.* (a few forward references) + updaters.apply("backends." .. what .. ".latebindings") + -- delayed / out-of-order locals: backends.[c|n]odeinjections.* (not all, only critical ones) + updaters.apply("backends.injections.latebindings") elseif trace then report("no backend named %a",what) end @@ -88,11 +106,7 @@ end statistics.register("used backend", function() local bc = backends.current - if bc ~= "unknown" then - return format("%s (%s)",bc,backends[bc].comment or "no comment") - else - return nil - end + return bc ~= "unknown" and bc or nil end) -- can best be here diff --git a/tex/context/base/mkxl/back-pdf.lmt b/tex/context/base/mkxl/back-pdf.lmt deleted file mode 100644 index fa564a195..000000000 --- a/tex/context/base/mkxl/back-pdf.lmt +++ /dev/null @@ -1,50 +0,0 @@ -if not modules then modules = { } end modules ['back-pdf'] = { - version = 1.001, - comment = "companion to back-pdf.mkiv", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", - copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files" -} - --- We hide the pdf table from users so that we can guarantee no interference with --- the way we manage resources, info, etc. Users should use the \type {lpdf} --- interface instead. If needed I will provide replacement functionality. - -local setmetatableindex = table.setmetatableindex - -local pdfsetcompression = lpdf.setcompression -local pdfimmediateobject = lpdf.immediateobject - -interfaces.implement { - name = "setpdfcompression", - arguments = { "integer", "integer" }, - actions = function(...) pdfsetcompression(...) end, -} - -do - - local dummy = function() end - local report = logs.reporter("backend") - - local function unavailable(t,k) - report("calling unavailable pdf.%s function",k) - t[k] = dummy - return dummy - end - - updaters.register("backend.update",function() - -- - -- For now we keep this for tikz. If really needed some more can be made - -- accessible but it has to happen in a controlled way then, for instance - -- by first loading or enabling some compatibility layer so that we can - -- trace possible interferences. - -- - pdf = { - immediateobj = pdfimmediateobject - } - setmetatableindex(pdf,unavailable) - end) - -end - -backends.install("pdf") diff --git a/tex/context/base/mkxl/back-res.lmt b/tex/context/base/mkxl/back-res.lmt index 3157b37ef..8e5bf3095 100644 --- a/tex/context/base/mkxl/back-res.lmt +++ b/tex/context/base/mkxl/back-res.lmt @@ -6,43 +6,49 @@ if not modules then modules = { } end modules ['back-res'] = { license = "see context related readme files" } -local context = context +local context = context -local trace = false trackers.register("backend", function(v) trace = v end) -local report = logs.reporter("backend") +local trace = false trackers.register("backend", function(v) trace = v end) +local report = logs.reporter("backend") -local scanners = tokens.scanners -local scankeyword = scanners.keyword -local scaninteger = scanners.integer -local scanstring = scanners.string -local scandimension = scanners.dimension -local scanword = scanners.word -local scanwhd = scanners.whd +local scanners = tokens.scanners +local scankeyword = scanners.keyword +local scaninteger = scanners.integer +local scanstring = scanners.string +local scandimension = scanners.dimension +local scanword = scanners.word +local scanwhd = scanners.whd -local implement = interfaces.implement -local constants = interfaces.constants -local variables = interfaces.variables +local implement = interfaces.implement +local constants = interfaces.constants +local variables = interfaces.variables + +local values = tokens.values +----- dimension_value = values.dimension +local cardinal_value = values.cardinal +----- direct_value = values.direct -- A box resource has an index. This happens to be an object number due to the pdf -- backend but in fact it's an abstraction. This is why we have explicit fetchers. -- The internal number (as in \Fm123) is yet another number. -local tex_saveboxresource = tex.saveboxresource -local tex_useboxresource = tex.useboxresource -local tex_getboxresourcebox = tex.getboxresourcebox -local tex_getboxresourcedimensions = tex.getboxresourcedimensions +-- this will change: +-- +-- tex.* : arglist, as in luatex +-- tex.boxresources : table + +local codeinjections = backends.codeinjections +local nodeinjections = backends.nodeinjections -updaters.register("backend.update",function() - tex_saveboxresource = tex.saveboxresource - tex_useboxresource = tex.useboxresource - tex_getboxresourcebox = tex.getboxresourcebox - tex_getboxresourcedimensions = tex.getboxresourcedimensions -end) +local savebox = function(...) return codeinjections.saveboxresource(...) end +local usebox = function(...) return nodeinjections.useboxresource(...) end +local getbox = function(...) return nodeinjections.getboxresourcebox(...) end +local getwhd = function(...) return codeinjections.getboxresourcedimensions(...) end -local savebox = function(...) return tex_saveboxresource(...) end -local usebox = function(...) return tex_useboxresource(...) end -local getbox = function(...) return tex_getboxresourcebox(...) end -local getwhd = function(...) return tex_getboxresourcedimensions(...) end +tex.saveboxresource = savebox +tex.useboxresource = usebox +tex.getboxresourcebox = getbox +tex.getboxresourcedimensions = getwhd local boxresources = { save = savebox, @@ -71,9 +77,10 @@ end local function lastsavedboxresourceindex() if trace then - report("\\lastsaveboxresource: index %i",lastindex) + report("\\lastsaveboxresourceindex: index %i",lastindex) end - context("%i",lastindex) + -- context("%i",lastindex) + return cardinal_value, lastindex or 0 end local function useboxresource() @@ -86,9 +93,47 @@ local function useboxresource() context(node) end -implement { name = "saveboxresource", actions = saveboxresource } -implement { name = "lastsavedboxresourceindex", actions = lastsavedboxresourceindex } -implement { name = "useboxresource", actions = useboxresource } +implement { + name = "saveboxresource", + actions = saveboxresource, +} +implement { + name = "lastsavedboxresourceindex", + public = true, + usage = "value", + actions = lastsavedboxresourceindex, +} +implement { + name = "useboxresource", + actions = useboxresource, +} + +-- used in pack + +do + + local nuts = nodes.nuts + local tonut = nodes.tonut + + local setwhd = nuts.setwhd + local setlist = nuts.setlist + + local new_hlist = nuts.pool.hlist + + function codeinjections.restoreboxresource(index) + local hbox = new_hlist() + local list, wd, ht, dp = usebox(index) + setlist(hbox,tonut(list)) + setwhd(hbox,wd,ht,dp) + return hbox -- so we return a nut ! + end + + function codeinjections.registerboxresource(n,offset) -- usecollected (arg 3) is a bit of a hack + local r = savebox(n,nil,true,true,0,offset or 0) -- direct, todo: accept functions as attr/resources + return r + end + +end -- image resources @@ -136,11 +181,13 @@ local function saveimageresource() end local function lastsavedimageresourceindex() - context("%i",lastindex or 0) +-- context("%i",lastindex or 0) + return cardinal_value, lastindex or 0 end local function lastsavedimageresourcepages() - context("%i",lastpages or 0) -- todo +-- context("%i",lastpages or 0) -- todo + return cardinal_value, lastpages or 0 end local function useimageresource() @@ -171,7 +218,26 @@ local function useimageresource() end end -implement { name = "saveimageresource", actions = saveimageresource } -implement { name = "lastsavedimageresourceindex", actions = lastsavedimageresourceindex } -implement { name = "lastsavedimageresourcepages", actions = lastsavedimageresourcepages } -implement { name = "useimageresource", actions = useimageresource } +implement { + name = "saveimageresource", + actions = saveimageresource, +} + +implement { + name = "lastsavedimageresourceindex", + public = true, + usage = "value", + actions = lastsavedimageresourceindex, +} + +implement { + name = "lastsavedimageresourcepages", + public = true, + usage = "value", + actions = lastsavedimageresourcepages, +} + +implement { + name = "useimageresource", + actions = useimageresource, +} diff --git a/tex/context/base/mkxl/back-res.mkxl b/tex/context/base/mkxl/back-res.mkxl index 8a18eef99..1febef18d 100644 --- a/tex/context/base/mkxl/back-res.mkxl +++ b/tex/context/base/mkxl/back-res.mkxl @@ -23,12 +23,12 @@ % todo: public implementors (we can update the lua code anyway) \permanent\protected\def\saveboxresource {\clf_saveboxresource} -\permanent\protected\def\lastsavedboxresourceindex {\numexpr\clf_lastsavedboxresourceindex\relax} +%permanent\protected\def\lastsavedboxresourceindex {\numexpr\clf_lastsavedboxresourceindex\relax} \permanent\protected\def\useboxresource {\clf_useboxresource} \permanent\protected\def\saveimageresource {\clf_saveimageresource} -\permanent\protected\def\lastsavedimageresourceindex{\numexpr\clf_lastsavedimageresourceindex\relax} -\permanent\protected\def\lastsavedimageresourcepages{\numexpr\clf_lastsavedimageresourcepages\relax} +%permanent\protected\def\lastsavedimageresourceindex{\numexpr\clf_lastsavedimageresourceindex\relax} +%permanent\protected\def\lastsavedimageresourcepages{\numexpr\clf_lastsavedimageresourcepages\relax} \permanent\protected\def\useimageresource {\clf_useimageresource} \protect \endinput diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index e1b48998e..a2edf83a6 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.10.15 13:57} +\newcontextversion{2021.10.18 23:11} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index 698a259ef..c227468ae 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.10.15 13:57} +\immutable\edef\contextversion{2021.10.18 23:11} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error @@ -151,6 +151,8 @@ \loadmkxlfile{layo-ini} \loadmkxlfile{node-ini} +\loadmkxlfile{node-ext} +\loadmkxlfile{node-syn} % \loadmkxlfile{cldf-bas} % basics / depends on nodes @@ -158,11 +160,10 @@ \loadmkxlfile{node-mig} %loadmkxlfile{node-pag} -\loadmkxlfile{driv-ini} +\loadmkxlfile{driv-ini} % after node-ini (ext) \loadmkxlfile{back-ini} \loadmkxlfile{back-res} -\loadmkxlfile{back-ext} \loadmkxlfile{cldf-bas} % basics / depends on nodes @@ -563,9 +564,10 @@ \loadmkxlfile{anch-loc} % for now here (after driver) \loadmkxlfile{back-exp} -\loadmkxlfile{back-pdf} -\loadmkxlfile{back-mps} -\loadmkxlfile{back-lua} + +\loadmkxlfile{back-imp-pdf} +\loadmkxlfile{back-imp-mps} +\loadmkxlfile{back-imp-lua} \loadmkxlfile{mlib-pdf} \loadmkxlfile{mlib-pps} diff --git a/tex/context/base/mkxl/core-def.mkxl b/tex/context/base/mkxl/core-def.mkxl index 96570bc36..839e9b260 100644 --- a/tex/context/base/mkxl/core-def.mkxl +++ b/tex/context/base/mkxl/core-def.mkxl @@ -112,6 +112,7 @@ \syst_files_load % for the moment here (before doc env) \setupoutput[pdf]% +% \setupoutput[lua]% % \clf_setdocumentcommandline \clf_setdocumentctxfile diff --git a/tex/context/base/mkxl/driv-ini.lmt b/tex/context/base/mkxl/driv-ini.lmt index 40b351d84..8b6c2e5ff 100644 --- a/tex/context/base/mkxl/driv-ini.lmt +++ b/tex/context/base/mkxl/driv-ini.lmt @@ -65,6 +65,14 @@ local installwhatsits do local leaderlevel = 0 local backends = backends + local trace = true + + local latelua = backends.latelua + local writeout = backends.writeout + local openout = backends.openout + local closeout = backends.closeout + + trackers.register("backends.whatsits",function(v) trace = v end) local function pushleaderlevel() leaderlevel = leaderlevel + 1 @@ -75,26 +83,26 @@ local installwhatsits do end local function flushlatelua(current,h,v) - -- Here we assume maganement by the lua function so currently we don't - -- check for leaderlevel. - return backends.latelua(current,h,v) + -- Here we assume management by the lua function so currently we don't + -- need to check for leaderlevel and it can even be counterproductive. + return latelua(current,h,v) end local function flushwriteout(current) if leaderlevel == 0 then - backends.writeout(current) + writeout(current) end end local function flushopenout(current) if leaderlevel == 0 then - backends.openout(current) + openout(current) end end local function flushcloseout(current) if leaderlevel == 0 then - backends.closeout(current) + closeout(current) end end @@ -110,8 +118,6 @@ local installwhatsits do local whatsitcodes = nodes.whatsitcodes - local trace = true trackers.register("backends.whatsits",function(v) trace = v end) - installwhatsits = function(name,flushers) -- latelua : specific @@ -135,54 +141,13 @@ local installwhatsits do return v end - -- flushers.whatsit = setmetatableindex ( { - -- [whatsitcodes.literal] = flushers.literal, - -- [whatsitcodes.latelua] = flushlatelua, - -- [whatsitcodes.userdefined] = flushuserdefined, - -- [whatsitcodes.savepos] = flushsavepos, - -- [whatsitcodes.save] = flushers.save, - -- [whatsitcodes.restore] = flushers.restore, - -- [whatsitcodes.setmatrix] = flushers.setmatrix, - -- [whatsitcodes.open] = flushopenout, - -- [whatsitcodes.close] = flushcloseout, - -- [whatsitcodes.write] = flushwriteout, - -- [whatsitcodes.startmatrix] = flushers.startmatrix, - -- [whatsitcodes.stopmatrix] = flushers.stopmatrix, - -- [whatsitcodes.startscaling] = flushers.startscaling, - -- [whatsitcodes.stopscaling] = flushers.stopscaling, - -- [whatsitcodes.startrotation] = flushers.startrotation, - -- [whatsitcodes.stoprotation] = flushers.stoprotation, - -- [whatsitcodes.startmirroring] = flushers.startmirroring, - -- [whatsitcodes.stopmirroring] = flushers.stopmirroring, - -- [whatsitcodes.startclipping] = flushers.startclipping, - -- [whatsitcodes.stopclipping] = flushers.stopclipping, - -- [whatsitcodes.setstate] = flushers.setstate, - -- }, checkagain ) - - -- -- sparse - - -- flushers.whatsit = setmetatableindex ( { - -- [whatsitcodes.latelua] = flushlatelua, - -- [whatsitcodes.userdefined] = flushuserdefined, - -- [whatsitcodes.savepos] = flushsavepos, - -- [whatsitcodes.open] = flushopenout, - -- [whatsitcodes.close] = flushcloseout, - -- [whatsitcodes.write] = flushwriteout, - -- }, checkagain ) - - -- -- delayed + -- delayed local whatsit ; whatsit = setmetatableindex ( { [whatsitcodes.literal] = flushers.literal or function(...) return checkagain(whatsit,whatsitcodes.literal )(...) end, - [whatsitcodes.latelua] = flushlatelua, - [whatsitcodes.userdefined] = flushuserdefined, - [whatsitcodes.savepos] = flushsavepos, [whatsitcodes.save] = flushers.save or function(...) return checkagain(whatsit,whatsitcodes.save )(...) end, [whatsitcodes.restore] = flushers.restore or function(...) return checkagain(whatsit,whatsitcodes.restore )(...) end, [whatsitcodes.setmatrix] = flushers.setmatrix or function(...) return checkagain(whatsit,whatsitcodes.setmatrix )(...) end, - [whatsitcodes.open] = flushopenout, - [whatsitcodes.close] = flushcloseout, - [whatsitcodes.write] = flushwriteout, [whatsitcodes.startmatrix] = flushers.startmatrix or function(...) return checkagain(whatsit,whatsitcodes.startmatrix )(...) end, [whatsitcodes.stopmatrix] = flushers.stopmatrix or function(...) return checkagain(whatsit,whatsitcodes.stopmatrix )(...) end, [whatsitcodes.startscaling] = flushers.startscaling or function(...) return checkagain(whatsit,whatsitcodes.startscaling )(...) end, @@ -194,6 +159,13 @@ local installwhatsits do [whatsitcodes.startclipping] = flushers.startclipping or function(...) return checkagain(whatsit,whatsitcodes.startclipping )(...) end, [whatsitcodes.stopclipping] = flushers.stopclipping or function(...) return checkagain(whatsit,whatsitcodes.stopclippin )(...) end, [whatsitcodes.setstate] = flushers.setstate or function(...) return checkagain(whatsit,whatsitcodes.setstate )(...) end, + -- + [whatsitcodes.latelua] = flushlatelua, + [whatsitcodes.userdefined] = flushuserdefined, + [whatsitcodes.savepos] = flushsavepos, + [whatsitcodes.open] = flushopenout, + [whatsitcodes.close] = flushcloseout, + [whatsitcodes.write] = flushwriteout, }, checkagain) flushers.whatsit = whatsit @@ -271,15 +243,15 @@ function drivers.enable(name) cleanup(currentinstance) stoptiming(drivers) end - currentdriver = name or "default" + currentdriver = name or "none" currentinstance = instances[currentdriver] if currentinstance then - local actions = currentinstance.actions - prepare = actions.prepare - wrapup = actions.wrapup - cleanup = actions.cleanup - convert = actions.convert - outputfilename = actions.outputfilename + local actions = currentinstance.actions + prepare = actions.prepare + wrapup = actions.wrapup + cleanup = actions.cleanup + convert = actions.convert + outputfilename = actions.outputfilename -- if prepare and not prepared[currentdriver] then starttiming(drivers) @@ -309,42 +281,6 @@ interfaces.implement { actions = drivers.enable, } --- The default driver: - -do - - local filename = nil - - drivers.install { - name = "default", -- "pdf" - actions = { - convert = drivers.converters.engine, - outputfilename = function(driver) - if not filename then - filename = addsuffix(tex.jobname,"pdf") - end - return filename - end, - }, - flushers = { - -- we always need this entry - }, - } - -end - --- No driver: - -do - - drivers.install { - name = "none", - actions = { }, - flushers = { }, - } - -end - do local function prepare(driver) @@ -366,10 +302,14 @@ do end --- - setmetatableindex(instances,function() return instances.default end) --- for now: +-- We default to no driver at all: + +drivers.install { + name = "none", + actions = { }, + flushers = { }, +} -drivers.enable("default") +drivers.enable("none") diff --git a/tex/context/base/mkxl/font-tex.lmt b/tex/context/base/mkxl/font-tex.lmt index c1908dc48..1c3c17a79 100644 --- a/tex/context/base/mkxl/font-tex.lmt +++ b/tex/context/base/mkxl/font-tex.lmt @@ -34,7 +34,7 @@ local function makeglyphbox(char,spec) width = b.width, height = b.height, depth = b.depth, - objnum = tex.saveboxresource(b,nil,nil,true), + objnum = tex.boxresources.save(b,nil,nil,true), } end @@ -95,7 +95,7 @@ function fonts.helpers.setboxdirectly(font,unicode,box) -- hash based on wd/ht/d height = box.height or 0, depth = box.depth or 0, unicode = unicode, - objnum = tex.saveboxresource(box,nil,nil,true), + objnum = tex.boxresources.save(box,nil,nil,true), } local specification = { code = newdata diff --git a/tex/context/base/mkxl/font-vfc.lmt b/tex/context/base/mkxl/font-vfc.lmt index 93e6fd4e5..c28b8b988 100644 --- a/tex/context/base/mkxl/font-vfc.lmt +++ b/tex/context/base/mkxl/font-vfc.lmt @@ -81,10 +81,26 @@ helpers.commands = utilities.storage.allocate { dummy = dummy, } +local codeinjections = backends.codeinjections +local vfstartcolor = codeinjections.vfstartcolor +local vfstopcolor = codeinjections.vfstopcolor +----- vfliteral = codeinjections.vfliteral + helpers.vfinjectors = { - -- backend specific: startcolor, stopcolor etc + -- startcolor = function(h,v,packet) codeinjections.vfstartcolor(h,v,packet) end, + -- stopcolor = function(h,v,packet) codeinjections.vfstartcolor(h,v,packet) end, + -- literal = function(h,v,packet) codeinjections.vfliteral (h,v,packer) end, + startcolor = function(h,v,packet) vfstartcolor(h,v,packet) end, + stopcolor = function(h,v,packet) vfstartcolor(h,v,packet) end, + -- literal = function(h,v,packet) vfliteral (h,v,packer) end, } +updaters.register("backends.injections.latebindings",function() + vfstartcolor = backends.codeinjections.vfstartcolor + vfstopcolor = backends.codeinjections.vfstopcolor + -- vfliteral = backends.codeinjections.vfliteral +end) + -- maybe round() local defaultline = 16384 diff --git a/tex/context/base/mkxl/grph-epd.lmt b/tex/context/base/mkxl/grph-epd.lmt new file mode 100644 index 000000000..6f9e44f63 --- /dev/null +++ b/tex/context/base/mkxl/grph-epd.lmt @@ -0,0 +1,55 @@ +if not modules then modules = { } end modules ['grph-epd'] = { + version = 1.001, + comment = "companion to grph-epd.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local variables = interfaces.variables +local settings_to_hash = utilities.parsers.settings_to_hash +local codeinjections = backends.registered.pdf.codeinjections + +local trace = false trackers.register("figures.merging", function(v) trace = v end) + +local report = logs.reporter("backend","merging") + +local function mergegoodies(optionlist) + local options = settings_to_hash(optionlist) + local yes = options[variables.yes] + local all = options[variables.all] + if next(options) then + report("% t",table.sortedkeys(options)) + end + if all or yes or options[variables.reference] then + codeinjections.mergereferences() + end + if all or options[variables.comment] then + codeinjections.mergecomments() + end + if all or yes or options[variables.bookmark] then + codeinjections.mergebookmarks() + end + if all or options[variables.field] then + codeinjections.mergefields() + end + if all or options[variables.layer] then + codeinjections.mergeviewerlayers() + end + codeinjections.flushmergelayer() +end + +function figures.mergegoodies(optionlist) + -- todo: we can use runlocal instead + context.stepwise(function() + -- we use stepwise because we might need to define symbols + -- for stamps that have no default appearance + mergegoodies(optionlist) + end) +end + +interfaces.implement { + name = "figure_mergegoodies", + actions = figures.mergegoodies, + arguments = "string" +} diff --git a/tex/context/base/mkiv/grph-epd.lua b/tex/context/base/mkxl/grph-epd.lua index 0993270f1..0993270f1 100644 --- a/tex/context/base/mkiv/grph-epd.lua +++ b/tex/context/base/mkxl/grph-epd.lua diff --git a/tex/context/base/mkxl/grph-epd.mkxl b/tex/context/base/mkxl/grph-epd.mkxl index 7ff9b8675..c8e5cd1c8 100644 --- a/tex/context/base/mkxl/grph-epd.mkxl +++ b/tex/context/base/mkxl/grph-epd.mkxl @@ -15,7 +15,7 @@ \unprotect -\registerctxluafile{grph-epd}{} +\registerctxluafile{grph-epd}{autosuffix} % hm, this one is globally overloaded diff --git a/tex/context/base/mkxl/grph-inc.lmt b/tex/context/base/mkxl/grph-inc.lmt index e19b48e49..8c4cb62b3 100644 --- a/tex/context/base/mkxl/grph-inc.lmt +++ b/tex/context/base/mkxl/grph-inc.lmt @@ -175,8 +175,8 @@ local imagekeys = { } local imagesizes = { - art = true, bleed = true, crop = true, - media = true, none = true, trim = true, + art = true, bleed = true, crop = true, + media = true, none = true, trim = true, } local imagetypes = { [0] = @@ -191,26 +191,28 @@ images.keys = imagekeys images.types = imagetypes images.sizes = imagesizes +local codeinjections = backends.codeinjections + local function createimage(specification) - return backends.codeinjections.newimage(specification) + return codeinjections.newimage(specification) end local function copyimage(specification) - return backends.codeinjections.copyimage(specification) + return codeinjections.copyimage(specification) end local function scanimage(specification) - return backends.codeinjections.scanimage(specification) + return codeinjections.scanimage(specification) end local function embedimage(specification) - -- write the image to file - return backends.codeinjections.embedimage(specification) + -- write the image to file + return codeinjections.embedimage(specification) end local function wrapimage(specification) -- create an image rule - return backends.codeinjections.wrapimage(specification) + return codeinjections.wrapimage(specification) end images.create = createimage @@ -1002,7 +1004,6 @@ local function locate(request) -- name, format, cache return foundname end -- - -- local askedformat = request.format if not askedformat or askedformat == "" or askedformat == "unknown" then askedformat = file.suffix(askedname) or "" @@ -1315,7 +1316,6 @@ function figures.identify(data) for i=1,#list do local identifier = list[i] local data = identifier(data) --- if data and (not data.status and data.status.status > 0) then if data and (not data.status and data.status.status > 0) then break end diff --git a/tex/context/base/mkxl/grph-rul.lmt b/tex/context/base/mkxl/grph-rul.lmt index d8da5f760..50a40155e 100644 --- a/tex/context/base/mkxl/grph-rul.lmt +++ b/tex/context/base/mkxl/grph-rul.lmt @@ -29,17 +29,14 @@ local a_colormodel = attributes.private('colormodel') local floor = math.floor local getrandom = utilities.randomizer.get -do - - local function unsupported() end - - ruleactions.mp = unsupported - ruleactions.fill = unsupported - ruleactions.draw = unsupported - ruleactions.stroke = unsupported - ruleactions.box = unsupported - -end +updaters.register("backends.injections.latebindings",function() + local codeinjections = backends.codeinjections + ruleactions.mp = codeinjections.ruleactionmp + ruleactions.fill = codeinjections.ruleactionfill + ruleactions.draw = codeinjections.ruleactiondraw + ruleactions.stroke = codeinjections.ruleactionstroke + ruleactions.box = codeinjections.ruleactionbox +end) interfaces.implement { name = "frule", diff --git a/tex/context/base/mkxl/lpdf-ano.lmt b/tex/context/base/mkxl/lpdf-ano.lmt index 763822707..85fe050a2 100644 --- a/tex/context/base/mkxl/lpdf-ano.lmt +++ b/tex/context/base/mkxl/lpdf-ano.lmt @@ -20,8 +20,6 @@ local lpegmatch = lpeg.match local formatters = string.formatters local sortedkeys, concat = table.sortedkeys, table.concat -local backends, lpdf = backends, lpdf - local trace_references = false trackers.register("references.references", function(v) trace_references = v end) local trace_destinations = false trackers.register("references.destinations", function(v) trace_destinations = v end) local trace_bookmarks = false trackers.register("references.bookmarks", function(v) trace_bookmarks = v end) @@ -45,9 +43,10 @@ local settings_to_array = utilities.parsers.settings_to_array local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex -local nodeinjections = backends.pdf.nodeinjections -local codeinjections = backends.pdf.codeinjections -local registrations = backends.pdf.registrations +local pdfbackend = backends.registered.pdf +local nodeinjections = pdfbackend.nodeinjections +local codeinjections = pdfbackend.codeinjections +local registrations = pdfbackend.registrations local javascriptcode = interactions.javascripts.code @@ -74,6 +73,7 @@ local getpos = jobpositions.getpos local gethpos = jobpositions.gethpos local getvpos = jobpositions.getvpos +local lpdf = lpdf local pdfdictionary = lpdf.dictionary local pdfarray = lpdf.array local pdfreference = lpdf.reference diff --git a/tex/context/base/mkxl/lpdf-col.lmt b/tex/context/base/mkxl/lpdf-col.lmt index ed6a4fa7b..c1499b75e 100644 --- a/tex/context/base/mkxl/lpdf-col.lmt +++ b/tex/context/base/mkxl/lpdf-col.lmt @@ -13,18 +13,19 @@ local concat = table.concat local round = math.round local formatters = string.formatters -local backends, lpdf, nodes = backends, lpdf, nodes - local allocate = utilities.storage.allocate -local nodeinjections = backends.pdf.nodeinjections -local codeinjections = backends.pdf.codeinjections -local registrations = backends.pdf.registrations +local pdfbackend = backends.registered.pdf +local nodeinjections = pdfbackend.nodeinjections +local codeinjections = pdfbackend.codeinjections +local registrations = pdfbackend.registrations +local nodes = nodes local nodepool = nodes.nuts.pool local register = nodepool.register local setstate = nodepool.setstate +local lpdf = lpdf local pdfconstant = lpdf.constant local pdfdictionary = lpdf.dictionary local pdfarray = lpdf.array @@ -580,7 +581,7 @@ function lpdf.pdfcolor(attribute) -- bonus, for pgf and friends return lpdfcolor(1,attribute) end -function lpdf.transparency(ct,default) -- kind of overlaps with transparencycode +local function lpdftransparency(ct,default) -- kind of overlaps with transparencycode -- beware, we need this hack because normally transparencies are not -- yet registered and therefore the number is not not known ... we -- might use the attribute number itself in the future @@ -596,6 +597,8 @@ function lpdf.transparency(ct,default) -- kind of overlaps with transparencycode end end +lpdf.transparency = lpdftransparency + function lpdf.colorvalue(model,ca,default) local cv = colorsvalue(ca) if cv then @@ -668,11 +671,10 @@ end -- by registering we getconversion for free (ok, at the cost of overhead) local intransparency = false -local pdfcolor = lpdf.color function lpdf.rgbcode(model,r,g,b) if colors.supported then - return pdfcolor(model,registercolor(nil,'rgb',r,g,b)) + return lpdfcolor(model,registercolor(nil,'rgb',r,g,b)) else return "" end @@ -680,7 +682,7 @@ end function lpdf.cmykcode(model,c,m,y,k) if colors.supported then - return pdfcolor(model,registercolor(nil,'cmyk',c,m,y,k)) + return lpdfcolor(model,registercolor(nil,'cmyk',c,m,y,k)) else return "" end @@ -688,7 +690,7 @@ end function lpdf.graycode(model,s) if colors.supported then - return pdfcolor(model,registercolor(nil,'gray',s)) + return lpdfcolor(model,registercolor(nil,'gray',s)) else return "" end @@ -696,7 +698,7 @@ end function lpdf.spotcode(model,n,f,d,p) if colors.supported then - return pdfcolor(model,registercolor(nil,'spot',n,f,d,p)) -- incorrect + return lpdfcolor(model,registercolor(nil,'spot',n,f,d,p)) -- incorrect else return "" end @@ -722,18 +724,12 @@ end do - local pdfprint, pdfcolor, pdftransparency - - updaters.register("backend.update.lpdf",function() - pdfprint = lpdf.print - pdfcolor = lpdf.color - pdftransparency = lpdf.transparency - end) + local lpdfprint = lpdf.print local c_cache = setmetatableindex(function(t,m) -- We inherit the outer transparency. local v = setmetatableindex(function(t,c) - local p = "q " .. pdfcolor(m,c) + local p = "q " .. lpdfcolor(m,c) t[c] = p return p end) @@ -742,10 +738,10 @@ do end) local t_cache = setmetatableindex(function(t,transparency) - local p = pdftransparency(transparency) + local p = lpdftransparency(transparency) local v = setmetatableindex(function(t,colormodel) local v = setmetatableindex(function(t,color) - local v = "q " .. pdfcolor(colormodel,color) .. " " .. p + local v = "q " .. lpdfcolor(colormodel,color) .. " " .. p t[color] = v return v end) @@ -756,35 +752,29 @@ do return v end) - updaters.register("backend.update.lpdf",function() - - local vfinjectors = fonts.helpers.vfinjectors - - vfinjectors.pdf = function(pos_h,pos_v,packet) - pdfprint(packet[2],packet[3]) - end - - vfinjectors.startcolor = function(pos_h,pos_v,packet) - local color = type(packet) == "table" and packet[2] or packet - if color then - local m, c = colortoattributes(color) - local t = transparencytoattribute(color) - if t and t ~= unsetvalue then - pdfprint("page", t_cache[t][m][c]) -- "q " .. pdfcolor(m,c) .. " " .. pdftransparency(t) - else - pdfprint("page", c_cache[m][c]) -- "q " .. pdfcolor(m,c)) - end + -- function codeinjections.vfliteral(pos_h,pos_v,packet) + -- lpdfprint(packet[2],packet[3]) + -- end + + function codeinjections.vfstartcolor(pos_h,pos_v,packet) + local color = type(packet) == "table" and packet[2] or packet + if color then + local m, c = colortoattributes(color) + local t = transparencytoattribute(color) + if t and t ~= unsetvalue then + lpdfprint("page", t_cache[t][m][c]) -- "q " .. lpdfcolor(m,c) .. " " .. lpdftransparency(t) else - pdfprint("page", "q") + lpdfprint("page", c_cache[m][c]) -- "q " .. lpdfcolor(m,c)) end + else + lpdfprint("page", "q") end + end - vfinjectors.stopcolor = function() - -- pdfprint("text", "Q") - pdfprint("page", "Q") - end - - end) + function codeinjections.vfstopcolor() + -- lpdfprint("text", "Q") + lpdfprint("page", "Q") + end end @@ -792,19 +782,16 @@ end do - local color = lpdf.color - local transparency = lpdf.transparency - local fonts = { } lpdf.fonts = fonts fonts.color_indirect = function(c,t) if c and t then - return color(1,c) .. " " .. transparency(t) + return lpdfcolor(1,c) .. " " .. lpdftransparency(t) elseif c then - return color(1,c) + return lpdfcolor(1,c) elseif t then - return transparency(t) + return lpdftransparency(t) else return false end diff --git a/tex/context/base/mkxl/lpdf-emb.lmt b/tex/context/base/mkxl/lpdf-emb.lmt index 926455bb8..9811c0843 100644 --- a/tex/context/base/mkxl/lpdf-emb.lmt +++ b/tex/context/base/mkxl/lpdf-emb.lmt @@ -2040,7 +2040,7 @@ local loadstreamdata = fonts.handlers.otf.loadstreamdata -- we can actually now number upwards (so not use fontid in /F) -local objects = setmetatableindex(function(t,k) +local objects = setmetatableindex(lpdf.usedfontobjects,function(t,k) -- defined in lpdf-lmt.lmt local v if type(k) == "number" then local h = getstreamhash(k) @@ -2063,7 +2063,7 @@ end) local n = 0 -local names = setmetatableindex(function(t,k) +local names = setmetatableindex(lpdf.usedfontnames,function(t,k) -- defined in lpdf-lmt.lmt local v if type(k) == "number" then local h = getstreamhash(k) diff --git a/tex/context/base/mkxl/lpdf-epa.lmt b/tex/context/base/mkxl/lpdf-epa.lmt index a88e48a5e..750c008fb 100644 --- a/tex/context/base/mkxl/lpdf-epa.lmt +++ b/tex/context/base/mkxl/lpdf-epa.lmt @@ -29,14 +29,16 @@ local report_comment = logs.reporter("backend","comment") local report_field = logs.reporter("backend","field") local report_outline = logs.reporter("backend","outline") -local lpdf = lpdf -local backends = backends local context = context -local nodeinjections = backends.pdf.nodeinjections +local pdfbackend = backends.registered.pdf +local nodeinjections = pdfbackend.nodeinjections +local codeinjections = pdfbackend.codeinjections +----- registrations = pdfbackend.registrations local setmacro = tokens.setters.macro +local lpdf = lpdf local pdfarray = lpdf.array local pdfdictionary = lpdf.dictionary local pdfconstant = lpdf.constant @@ -62,7 +64,6 @@ local loadpdffile = lpdf.epdf.load local nameonly = file.nameonly local variables = interfaces.variables -local codeinjections = backends.pdf.codeinjections ----- urlescaper = lpegpatterns.urlescaper ----- utftohigh = lpegpatterns.utftohigh local escapetex = characters.filters.utf.private.escape @@ -77,7 +78,7 @@ local layerspec = { "epdfcontent" } -local getpos = function() getpos = backends.codeinjections.getpos return getpos() end +local getpos = function() getpos = codeinjections.getpos return getpos() end local collected = allocate() local tobesaved = allocate() @@ -1013,7 +1014,7 @@ function codeinjections.mergebookmarks(specification) end if specification then local fullname = specification.fullname - local bookmarks = backends.codeinjections.getbookmarks(fullname) + local bookmarks = codeinjections.getbookmarks(fullname) local realpage = tonumber(specification.page) or 1 for i=1,#bookmarks do local b = bookmarks[i] diff --git a/tex/context/base/mkxl/lpdf-fld.lmt b/tex/context/base/mkxl/lpdf-fld.lmt index 13ebd6c44..3077b19c0 100644 --- a/tex/context/base/mkxl/lpdf-fld.lmt +++ b/tex/context/base/mkxl/lpdf-fld.lmt @@ -62,22 +62,20 @@ local trace_fields = false trackers.register("backends.fields", function(v) tra local report_fields = logs.reporter("backend","fields") -local backends, lpdf = backends, lpdf - local variables = interfaces.variables local context = context local references = structures.references local settings_to_array = utilities.parsers.settings_to_array -local pdfbackend = backends.pdf - +local pdfbackend = backends.registered.pdf local nodeinjections = pdfbackend.nodeinjections local codeinjections = pdfbackend.codeinjections local registrations = pdfbackend.registrations local registeredsymbol = codeinjections.registeredsymbol +local lpdf = lpdf local pdfstream = lpdf.stream local pdfdictionary = lpdf.dictionary local pdfarray = lpdf.array diff --git a/tex/context/base/mkxl/lpdf-fmt.lmt b/tex/context/base/mkxl/lpdf-fmt.lmt index f83432d48..7ceacc62d 100644 --- a/tex/context/base/mkxl/lpdf-fmt.lmt +++ b/tex/context/base/mkxl/lpdf-fmt.lmt @@ -19,15 +19,16 @@ local trace_variables = false trackers.register("backend.variables", function(v local report_backend = logs.reporter("backend","profiles") -local backends, lpdf = backends, lpdf - -local codeinjections = backends.pdf.codeinjections +local pdfbackend = backends.registered.pdf +----- nodeinjections = pdfbackend.nodeinjections +local codeinjections = pdfbackend.codeinjections local variables = interfaces.variables local viewerlayers = attributes.viewerlayers local colors = attributes.colors local transparencies = attributes.transparencies +local lpdf = lpdf local pdfdictionary = lpdf.dictionary local pdfarray = lpdf.array local pdfconstant = lpdf.constant diff --git a/tex/context/base/mkxl/lpdf-grp.lmt b/tex/context/base/mkxl/lpdf-grp.lmt index e5d04c5a9..7c4001467 100644 --- a/tex/context/base/mkxl/lpdf-grp.lmt +++ b/tex/context/base/mkxl/lpdf-grp.lmt @@ -11,17 +11,15 @@ local formatters, gsub = string.formatters, string.gsub local concat = table.concat local round = math.round -local backends, lpdf = backends, lpdf - -local nodeinjections = backends.pdf.nodeinjections - local colors = attributes.colors local basepoints = number.dimenfactors.bp -local nodeinjections = backends.pdf.nodeinjections -local codeinjections = backends.pdf.codeinjections -local registrations = backends.pdf.registrations +local pdfbackend = backends.registered.pdf +local nodeinjections = pdfbackend.nodeinjections +local codeinjections = pdfbackend.codeinjections +local registrations = pdfbackend.registrations +local lpdf = lpdf local pdfdictionary = lpdf.dictionary local pdfarray = lpdf.array local pdfconstant = lpdf.constant @@ -295,4 +293,4 @@ function lpdf.patternstream(n,width,height) return f_pattern("Pt" .. n,width*basepoints,height*basepoints) end -backends.pdf.codeinjections.registerpattern = lpdf.registerpattern +codeinjections.registerpattern = lpdf.registerpattern diff --git a/tex/context/base/mkxl/lpdf-img.lmt b/tex/context/base/mkxl/lpdf-img.lmt index 8e7427ae6..df658c236 100644 --- a/tex/context/base/mkxl/lpdf-img.lmt +++ b/tex/context/base/mkxl/lpdf-img.lmt @@ -59,6 +59,8 @@ local pdfflushstreamobject = lpdf.flushstreamobject local pdfmajorversion = lpdf.majorversion local pdfminorversion = lpdf.minorversion +local codeinjections = backends.registered.pdf.codeinjections + local createimage = images.create local zlibcompress = xzip.compress @@ -1363,7 +1365,7 @@ do } end - backends.pdf.codeinjections.bitmap = injectors.bitmap + codeinjections.bitmap = injectors.bitmap end @@ -1390,6 +1392,6 @@ end -- return true -- end -backends.pdf.codeinjections.jpg = lpdf.injectors.jpg -backends.pdf.codeinjections.jp2 = lpdf.injectors.jp2 -backends.pdf.codeinjections.png = lpdf.injectors.png +codeinjections.jpg = lpdf.injectors.jpg +codeinjections.jp2 = lpdf.injectors.jp2 +codeinjections.png = lpdf.injectors.png diff --git a/tex/context/base/mkxl/lpdf-ini.lmt b/tex/context/base/mkxl/lpdf-ini.lmt index 1ce7c5adc..7979b80f8 100644 --- a/tex/context/base/mkxl/lpdf-ini.lmt +++ b/tex/context/base/mkxl/lpdf-ini.lmt @@ -75,25 +75,14 @@ local context = context -- In ConTeXt MkIV we use utf8 exclusively so all strings get mapped onto a hex -- encoded utf16 string type between <>. We could probably save some bytes by using --- strings between () but then we end up with escaped ()\ too. +-- strings between () but then we end up with escaped ()\ characters too. pdf = type(pdf) == "table" and pdf or { } local factor = number.dimenfactors.bp -local codeinjections = { } -local nodeinjections = { } - -local backends = backends or { } - -local pdfbackend = { - comment = "backend for directly generating pdf output", - nodeinjections = nodeinjections, - codeinjections = codeinjections, - registrations = { }, - tables = { }, -} - -backends.pdf = pdfbackend +local pdfbackend = backends.registered.pdf +local codeinjections = pdfbackend.codeinjections +local nodeinjections = pdfbackend.nodeinjections lpdf = lpdf or { } local lpdf = lpdf @@ -107,10 +96,29 @@ end) local trace_finalizers = false trackers.register("backend.finalizers", function(v) trace_finalizers = v end) local trace_resources = false trackers.register("backend.resources", function(v) trace_resources = v end) +do + + -- This is for a future feature (still under investigation and consideration). So, + -- it is work in progress (and brings a harmless overhead for now). + + local initializers = { } + + function lpdf.registerinitializer(initialize) + initializers[#initializers+1] = initialize + end + + function lpdf.initialize(f) + for i=1,#initializers do + initializers[i]() + end + end + +end + local pdfreserveobject local pdfimmediateobject -updaters.register("backend.update.lpdf",function() +updaters.register("backends.pdf.latebindings",function() pdfreserveobject = lpdf.reserveobject pdfimmediateobject = lpdf.immediateobject end) @@ -119,7 +127,7 @@ do local pdfgetmatrix, pdfhasmatrix, pdfgetpos - updaters.register("backend.update.lpdf",function() + updaters.register("backends.pdf.latebindings",function() job.positions.registerhandlers { getpos = drivers.getpos, getrpos = drivers.getrpos, @@ -771,6 +779,8 @@ end resetpageproperties() +lpdf.registerinitializer(resetpageproperties) + local function addtopageresources (k,v) pageresources [k] = v end local function addtopageattributes (k,v) pageattributes [k] = v end local function addtopagesattributes(k,v) pagesattributes[k] = v end @@ -830,13 +840,12 @@ function lpdf.finalizepage(shipout) end end +local finalized = false + function lpdf.finalizedocument() - if not environment.initex then + if not environment.initex and not finalized then run(documentfinalizers,"document") - function lpdf.finalizedocument() - -- report_finalizing("serious error: the document is finalized multiple times") - function lpdf.finalizedocument() end - end + finalized = true end end @@ -891,7 +900,6 @@ do local function flushcatalog() if checkcatalog() then catalog.Type = nil --- pdfsetcatalog(catalog()) end end @@ -951,6 +959,12 @@ do local d_extgstates, d_colorspaces, d_patterns, d_shades local p_extgstates, p_colorspaces, p_patterns, p_shades + lpdf.registerinitializer(function() + r_extgstates = nil ; r_colorspaces = nil ; r_patterns = nil ; r_shades = nil ; + d_extgstates = nil ; d_colorspaces = nil ; d_patterns = nil ; d_shades = nil ; + p_extgstates = nil ; p_colorspaces = nil ; p_patterns = nil ; p_shades = nil ; + end) + local function checkextgstates () if d_extgstates then addtopageresources("ExtGState", p_extgstates ) end end local function checkcolorspaces() if d_colorspaces then addtopageresources("ColorSpace",p_colorspaces) end end local function checkpatterns () if d_patterns then addtopageresources("Pattern", p_patterns ) end end @@ -969,7 +983,7 @@ do local pdfgetfontobjectnumber - updaters.register("backend.update.lpdf",function() + updaters.register("backends.pdf.latebindings",function() pdfgetfontobjectnumber = lpdf.getfontobjectnumber end) @@ -1356,11 +1370,16 @@ end do - -- This is obsolete but old viewers might still use it as directive - -- for what to send to a postscript printer. + -- This is obsolete but old viewers might still use it as directive for what to + -- send to a postscript printer. local a_procset, d_procset + lpdf.registerinitializer(function() + a_procset = nil + d_procset = nil + end) + function lpdf.procset(dict) if not a_procset then a_procset = pdfarray { diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index e1637228a..fb7b8ac63 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -42,7 +42,6 @@ local loaddata = io.loaddata local bpfactor = number.dimenfactors.bp local osuuid = os.uuid -local zlibcompress = xzip.compress local zlibcompresssize = xzip.compresssize local nuts = nodes.nuts @@ -66,14 +65,6 @@ local pdfimmediateobject -- forward reference local pdfincludeimage -- forward reference -local pdfgetfontname -- elsewhere -local pdfgetfontobjectnumber -- elsewhere - -updaters.register("backend.update.lpdf",function() - pdfgetfontname = lpdf.getfontname - pdfgetfontobjectnumber = lpdf.getfontobjectnumber -end) - local pdf_pages = pdfconstant("Pages") local pdf_page = pdfconstant("Page") local pdf_xobject = pdfconstant("XObject") @@ -94,6 +85,14 @@ local trace_objects = false trackers.register("backend.objects", functio local trace_details = false trackers.register("backend.details", function(v) trace_details = v end) local trace_indices = false trackers.register("backend.fonts.details", function(v) trace_indices = v end) +-- These two tables used a font id as index and will be metatabled in lpdf-emb.lmt: + +local usedfontnames = { } +local usedfontobjects = { } + +lpdf.usedfontnames = usedfontnames +lpdf.usedfontobjects = usedfontobjects + -- experiment: local function compressdata(data,size) @@ -131,7 +130,8 @@ local cmrx, cmry, cmsx, cmsy, cmtx, cmty local tmef local function usefont(t,k) -- a bit redundant hash - local v = pdfgetfontname(k) + -- local v = pdfgetfontname(k) + local v = usedfontnames[k] t[k] = v return v end @@ -987,6 +987,10 @@ local localconverter = nil -- will be set local flushimage do + local pdfbackend = backends.registered.pdf + local nodeinjections = pdfbackend.nodeinjections + local codeinjections = pdfbackend.codeinjections + local newimagerule = nuts.pool.imagerule local newboxrule = nuts.pool.boxrule @@ -1045,13 +1049,19 @@ local flushimage do lpdf.getxformname = getxformname - local function saveboxresource(box,attributes,resources,immediate,kind,margin) + local pdfcollectedresources = lpdf.collectedresources + + function codeinjections.saveboxresource(box,attributes,resources,immediate,kind,margin) n = n + 1 local immediate = true local margin = margin or 0 -- or dimension local objnum = pdfreserveobject() local list = tonut(type(box) == "number" and tex.takebox(box) or box) -- + if resources == true then + resources = pdfcollectedresources() + end + -- local width, height, depth = getwhd(list) -- local l = { @@ -1078,7 +1088,7 @@ local flushimage do return objnum end - local function useboxresource(index,wd,ht,dp) + function nodeinjections.useboxresource(index,wd,ht,dp) local l = boxresources[index] if l then if wd or ht or dp then @@ -1104,20 +1114,15 @@ local flushimage do end end - local function getboxresourcebox(index) + nodeinjections.getboxresourcedimensions = getboxresourcedimensions + + function codeinjections.getboxresourcebox(index) local l = boxresources[index] if l then return l.list end end - updaters.register("backend.update.lpdf",function() - tex.saveboxresource = saveboxresource - tex.useboxresource = useboxresource - tex.getboxresourcedimensions = getboxresourcedimensions - tex.getboxresourcebox = getboxresourcebox - end) - -- a bit of a mess: index is now objnum but that has to change to a proper index -- ... an engine inheritance @@ -1475,7 +1480,7 @@ end --- basics -local wrapup, registerpage do +local wrapupdocument, registerpage do local pages = { } local maxkids = 10 @@ -1550,7 +1555,7 @@ local wrapup, registerpage do -- lpdf.setpageorder(t) -- end - wrapup = function(driver) + wrapupdocument = function(driver) -- hook (to reshuffle pages) local pagetree = { } @@ -1730,7 +1735,8 @@ local finalize do if next(usedfonts) then fonts = pdfdictionary { } for k, v in next, usedfonts do - fonts[f_font(v)] = pdfreference(pdfgetfontobjectnumber(k)) -- we can overload for testing +-- fonts[f_font(v)] = pdfreference(pdfgetfontobjectnumber(k)) -- we can overload for testing + fonts[f_font(v)] = pdfreference(usedfontobjects[k]) -- we can overload for testing end end @@ -1890,17 +1896,6 @@ local finalize do end -updaters.register("backend.update",function() - local saveboxresource = tex.boxresources.save - -- - -- also in lpdf-res .. brrr .. needs fixing - -- - backends.codeinjections.registerboxresource = function(n,offset) - local r = saveboxresource(n,nil,nil,false,0,offset or 0) - return r - end -end) - -- now comes the pdf file handling local objects = { } @@ -2429,7 +2424,6 @@ pdfimmediateobject = function(a,b,c,d) end -- todo: immediate if kind == "stream" then --- flushstreamobj(data,objnum,attr,compresslevel and compresslevel > 0 or nil,nolength) -- nil == auto flushstreamobj(data,objnum,attr,compresslevel,nolength) -- nil == auto elseif objectstream and objcompression ~= false then addtocache(objnum,data) @@ -2747,7 +2741,9 @@ do -- reimplement what we need in context. This will change completely i.e. -- we will drop the low level interface! - local codeinjections = backends.pdf.codeinjections + local pdfbackend = backends.registered.pdf + local nodeinjections = pdfbackend.nodeinjections + local codeinjections = pdfbackend.codeinjections local imagetypes = images.types -- pdf png jpg jp2 jbig2 stream local img_none = imagetypes.none @@ -2828,7 +2824,6 @@ do specification.type = kind specification.kind = kind end --- flushstreamobj(stream,objnum,dict,compresslevel and compresslevel > 0 or nil,nolength) flushstreamobj(stream,objnum,dict,compresslevel,nolength) specification.objnum = objnum specification.rotation = specification.rotation or 0 @@ -2885,108 +2880,7 @@ do lpdf.includeimage = pdfincludeimage -end -- ) - -do - - -- todo: an md5 or sha2 hash can save space - -- todo: make a type 3 font instead - -- todo: move to lpdf namespace - - local pdfimage - local newpdf - local openpdf - local closepdf - local copypage - - updaters.register("backend.update.lpdf",function() - pdfimage = lpdf.epdf.image - newpdf = pdfimage.new - openpdf = pdfimage.open - closepdf = pdfimage.close - copypage = pdfimage.copy - end) - - local embedimage = images.embed - - local nofstreams = 0 - local topdf = { } - local toidx = { } - - local function storedata_s(pdf) - local idx = toidx[pdf] - if not idx then - nofstreams = nofstreams + 1 - idx = nofstreams - toidx[pdf] = nofstreams - topdf[idx] = pdf - end - return idx - end - - local function vfimage_s(id,wd,ht,dp,pos_h,pos_v) - local index = topdf[id] - if type(index) == "string" then - local pdfdoc = newpdf(index,#index) - local image = copypage(pdfdoc) - local bbox = image.bbox - image.width = bbox[3] - bbox[1] - image.height = bbox[4] - bbox[2] - embedimage(image) - index = image.index - topdf[id] = index - end - flushimage(index,wd,ht,dp,pos_h,pos_v) - end - - local function storedata_n(name,page) - local idx = toidx[pdf] - if not idx then - nofstreams = nofstreams + 1 - idx = nofstreams - toidx[pdf] = nofstreams - topdf[idx] = pdf - end - return idx - end - - -- We need to have a way to close such a pdf ... esp for fonts. - - local pdfdocs = { } - - local function vfimage_n(name,page,wd,ht,dp,pos_h,pos_v) - local d = pdfdocs[name] - if not d then - d = { doc = openpdf(name), pages = { } } - pdfdocs[name] = d - end - local index = d.pages[page] - if not index then - local image = copypage(d.doc,page) - local bbox = image.bbox - image.width = bbox[3] - bbox[1] - image.height = bbox[4] - bbox[2] - embedimage(image) - index = image.index - d.pages[page] = index - end - flushimage(index,wd,ht,dp,pos_h,pos_v) - end - - function lpdf.pdfvfimage(wd,ht,dp,data,name) - if type(data) == "number" then - return { "lua", function(font,char,pos_h,pos_v) - vfimage_n(name,data,wd,ht,dp,pos_h,pos_v) - end } - else - return { "lua", function(font,char,pos_h,pos_v) - local id = storedata_s(data) - vfimage_s(id,wd,ht,dp,pos_h,pos_v) - end } - end - end - -end -- ) +end -- The driver. @@ -3003,12 +2897,24 @@ do return pdfname end +-- local outputfilename ; do -- old todo usedname in ^^ +-- local filename = nil +-- outputfilename = function(driver,usedname) +-- if usedname and usedname ~= "" then +-- filename = addsuffix(usedname,"pdf") +-- elseif not filename or filename == "" then +-- filename = addsuffix(tex.jobname,"pdf") +-- end +-- return filename +-- end +-- end + -- todo: prevent twice local function prepare(driver) if not environment.initex then - updaters.apply("backend.update.lpdf") - updaters.apply("backend.update") + -- + backends.initialize("pdf") -- also does bindings -- pdfname = tex.jobname .. ".pdf" openfile(pdfname) @@ -3017,6 +2923,7 @@ do if pdfname then lpdf.finalizedocument() closefile() + pdfname = nil end end) -- @@ -3026,7 +2933,7 @@ do end end) -- - lpdf.registerdocumentfinalizer(wrapup,nil,"wrapping up") + lpdf.registerdocumentfinalizer(wrapupdocument,nil,"wrapping up") -- statistics.register("result saved in file", function() local outputfilename = environment.outputfilename or environment.jobname or tex.jobname or "<unset>" diff --git a/tex/context/base/mkxl/lpdf-mis.lmt b/tex/context/base/mkxl/lpdf-mis.lmt index ca018e9f0..2b82f8adc 100644 --- a/tex/context/base/mkxl/lpdf-mis.lmt +++ b/tex/context/base/mkxl/lpdf-mis.lmt @@ -20,15 +20,15 @@ local format, gsub, formatters = string.format, string.gsub, string.formatters local concat, flattened = table.concat, table.flattened local settings_to_array = utilities.parsers.settings_to_array -local backends, lpdf, nodes = backends, lpdf, nodes - -local nodeinjections = backends.pdf.nodeinjections -local codeinjections = backends.pdf.codeinjections -local registrations = backends.pdf.registrations +local pdfbackend = backends.registered.pdf +local nodeinjections = pdfbackend.nodeinjections +local codeinjections = pdfbackend.codeinjections +local registrations = pdfbackend.registrations local getpagedimensions = layouts.getpagedimensions local getcanvas = layouts.getcanvas +local nodes = nodes local nuts = nodes.nuts local copy_node = nuts.copy @@ -36,6 +36,7 @@ local nodepool = nuts.pool local setstate = nodepool.setstate local register = nodepool.register +local lpdf = lpdf local pdfdictionary = lpdf.dictionary local pdfarray = lpdf.array local pdfconstant = lpdf.constant diff --git a/tex/context/base/mkxl/lpdf-ren.lmt b/tex/context/base/mkxl/lpdf-ren.lmt index a50dcdc79..0343ab76a 100644 --- a/tex/context/base/mkxl/lpdf-ren.lmt +++ b/tex/context/base/mkxl/lpdf-ren.lmt @@ -14,11 +14,11 @@ local formatters = string.formatters local settings_to_array = utilities.parsers.settings_to_array local getrandom = utilities.randomizer.get -local backends, lpdf, nodes, node = backends, lpdf, nodes, node +local pdfbackend = backends.registered.pdf +local nodeinjections = pdfbackend.nodeinjections +local codeinjections = pdfbackend.codeinjections +local registrations = pdfbackend.registrations -local nodeinjections = backends.pdf.nodeinjections -local codeinjections = backends.pdf.codeinjections -local registrations = backends.pdf.registrations local viewerlayers = attributes.viewerlayers local references = structures.references @@ -36,6 +36,7 @@ local v_reset = variables.reset local v_auto = variables.auto local v_random = variables.random +local lpdf = lpdf local pdfconstant = lpdf.constant local pdfdictionary = lpdf.dictionary local pdfarray = lpdf.array @@ -48,7 +49,9 @@ local addtocatalog = lpdf.addtocatalog local escaped = lpdf.escaped +local nodes = nodes local nuts = nodes.nuts + local copy_node = nuts.copy local nodepool = nuts.pool diff --git a/tex/context/base/mkxl/lpdf-res.lmt b/tex/context/base/mkxl/lpdf-res.lmt deleted file mode 100644 index d3c591343..000000000 --- a/tex/context/base/mkxl/lpdf-res.lmt +++ /dev/null @@ -1,41 +0,0 @@ -if not modules then modules = { } end modules ['lpdf-res'] = { - version = 1.001, - comment = "companion to lpdf-ini.mkiv", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", - copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files" -} - -local codeinjections = backends.codeinjections - -local nuts = nodes.nuts -local tonut = nodes.tonut - -local setwhd = nuts.setwhd -local setlist = nuts.setlist - -local new_hlist = nuts.pool.hlist - -local boxresources = tex.boxresources -local saveboxresource = boxresources.save -local useboxresource = boxresources.use -local getboxresourcedimensions = boxresources.getdimensions - -local pdfcollectedresources = lpdf.collectedresources - -function codeinjections.registerboxresource(n,offset) - local r = saveboxresource(n,nil,pdfcollectedresources(),true,0,offset or 0) -- direct, todo: accept functions as attr/resources - return r -end - -function codeinjections.restoreboxresource(index) - local hbox = new_hlist() - local list, wd, ht, dp = useboxresource(index) - setlist(hbox,tonut(list)) - setwhd(hbox,wd,ht,dp) - return hbox -- so we return a nut ! -end - -function codeinjections.boxresourcedimensions(index) - return getboxresourcedimensions(index) -end diff --git a/tex/context/base/mkxl/lpdf-rul.lmt b/tex/context/base/mkxl/lpdf-rul.lmt index baf4509ed..f0676dee9 100644 --- a/tex/context/base/mkxl/lpdf-rul.lmt +++ b/tex/context/base/mkxl/lpdf-rul.lmt @@ -33,6 +33,8 @@ local floor = math.floor local getrandom = utilities.randomizer.get local formatters = string.formatters +local codeinjections = backends.registered.pdf.codeinjections + -- This is very pdf specific. Maybe move some to lpdf-rul.lua some day. local pdfprint ; pdfprint = function(...) pdfprint = lpdf.print return pdfprint(...) end @@ -97,7 +99,7 @@ def RuleColor = %color% enddef ; local initialized = false ; - local rule_mp = function(p,h,v,i,n) + local function rule_mp(p,h,v,i,n) local name = p.name or "fake:rest" local code = (predefined[name] or predefined["fake:rest"]) { data = p.data or "", @@ -129,9 +131,7 @@ def RuleColor = %color% enddef ; end end - updaters.register("backend.update.lpdf",function() - ruleactions.mp = rule_mp - end) + codeinjections.ruleactionmp = rule_mp end @@ -373,12 +373,10 @@ h %s]] end end - updaters.register("backend.update.lpdf",function() - ruleactions.fill = rule_any - ruleactions.draw = rule_any - ruleactions.stroke = rule_any - ruleactions.box = rule_box - end) + codeinjections.ruleactionfill = rule_any + codeinjections.ruleactiondraw = rule_any + codeinjections.ruleactionstroke = rule_any + codeinjections.ruleactionbox = rule_box end diff --git a/tex/context/base/mkxl/lpdf-tag.lmt b/tex/context/base/mkxl/lpdf-tag.lmt index 5b52f56fd..7aa9edb9b 100644 --- a/tex/context/base/mkxl/lpdf-tag.lmt +++ b/tex/context/base/mkxl/lpdf-tag.lmt @@ -18,16 +18,14 @@ local trace_info = false trackers.register("structures.tags.info", function(v) local report_tags = logs.reporter("backend","tags") -local backends = backends -local lpdf = lpdf -local nodes = nodes - -local nodeinjections = backends.pdf.nodeinjections -local codeinjections = backends.pdf.codeinjections +local pdfbackend = backends.registered.pdf +local nodeinjections = pdfbackend.nodeinjections +local codeinjections = pdfbackend.codeinjections local enableaction = nodes.tasks.enableaction local disableaction = nodes.tasks.disableaction +local lpdf = lpdf local pdfdictionary = lpdf.dictionary local pdfarray = lpdf.array local pdfboolean = lpdf.boolean @@ -45,6 +43,7 @@ local pdfpagereference = lpdf.pagereference local texgetcount = tex.getcount +local nodes = nodes local nodecodes = nodes.nodecodes local hlist_code = nodecodes.hlist diff --git a/tex/context/base/mkxl/lpdf-u3d.lmt b/tex/context/base/mkxl/lpdf-u3d.lmt index 54dc8a227..5307818d0 100644 --- a/tex/context/base/mkxl/lpdf-u3d.lmt +++ b/tex/context/base/mkxl/lpdf-u3d.lmt @@ -21,10 +21,9 @@ local tonumber = tonumber local formatters, find = string.formatters, string.find local cos, sin, sqrt, pi, atan2, abs = math.cos, math.sin, math.sqrt, math.pi, math.atan2, math.abs -local backends, lpdf = backends, lpdf - -local nodeinjections = backends.pdf.nodeinjections +local nodeinjections = backends.registered.pdf.nodeinjections +local lpdf = lpdf local pdfconstant = lpdf.constant local pdfboolean = lpdf.boolean local pdfunicode = lpdf.unicode diff --git a/tex/context/base/mkxl/lpdf-wid.lmt b/tex/context/base/mkxl/lpdf-wid.lmt index 2999eb281..3047402bc 100644 --- a/tex/context/base/mkxl/lpdf-wid.lmt +++ b/tex/context/base/mkxl/lpdf-wid.lmt @@ -40,9 +40,6 @@ local sortedhash, sortedkeys = table.sortedhash, table.sortedkeys local report_media = logs.reporter("backend","media") local report_attachment = logs.reporter("backend","attachment") -local backends = backends -local lpdf = lpdf -local nodes = nodes local context = context local texgetcount = tex.getcount @@ -50,9 +47,10 @@ local getmacro = tokens.getters.macro local hpacknode = nodes.hpack -local nodeinjections = backends.pdf.nodeinjections -local codeinjections = backends.pdf.codeinjections -local registrations = backends.pdf.registrations +local pdfbackend = backends.registered.pdf +local nodeinjections = pdfbackend.nodeinjections +local codeinjections = pdfbackend.codeinjections +local registrations = pdfbackend.registrations local executers = structures.references.executers local variables = interfaces.variables @@ -67,6 +65,8 @@ local v_compress = variables.compress local v_list = variables.list local v_title = variables.title +local lpdf = lpdf + local pdfconstant = lpdf.constant local pdfnull = lpdf.null local pdfdictionary = lpdf.dictionary diff --git a/tex/context/base/mkxl/lpdf-xmp.lmt b/tex/context/base/mkxl/lpdf-xmp.lmt index deeb1e135..a5be8bfe0 100644 --- a/tex/context/base/mkxl/lpdf-xmp.lmt +++ b/tex/context/base/mkxl/lpdf-xmp.lmt @@ -19,10 +19,11 @@ local trace_info = false trackers.register("backend.info", function(v) trace_in local report_xmp = logs.reporter("backend","xmp") local report_info = logs.reporter("backend","info") -local backends, lpdf = backends, lpdf - -local codeinjections = backends.pdf.codeinjections -- normally it is registered +local backends = backends +local pdfbackend = backends.registered.pdf +local codeinjections = pdfbackend.codeinjections +local lpdf = lpdf local pdfdictionary = lpdf.dictionary local pdfconstant = lpdf.constant local pdfreference = lpdf.reference diff --git a/tex/context/base/mkxl/mlib-lmt.lmt b/tex/context/base/mkxl/mlib-lmt.lmt index 7bbccb16b..ba86f0758 100644 --- a/tex/context/base/mkxl/mlib-lmt.lmt +++ b/tex/context/base/mkxl/mlib-lmt.lmt @@ -136,7 +136,7 @@ function mp.lmt_svg_include() end registerscript("remaptext", function() - local parameters = metapost.scanparameters() + local parameters = metapost.scanparameters(true) -- gobble the semi colon (avoid lookahead) if parameters and parameters.label then metapost.remaptext(parameters) end diff --git a/tex/context/base/mkxl/mlib-scn.lmt b/tex/context/base/mkxl/mlib-scn.lmt index 33aa74ad2..fcf9e73c3 100644 --- a/tex/context/base/mkxl/mlib-scn.lmt +++ b/tex/context/base/mkxl/mlib-scn.lmt @@ -731,8 +731,10 @@ end -- return false -- end -function metapost.scanparameters() --- scantoken() -- we scan the semicolon +function metapost.scanparameters(gobblesemicolon) + if gobblesemicolon then + scantoken() -- we scan the semicolon + end return get_parameters() end diff --git a/tex/context/base/mkxl/mlib-svg.lmt b/tex/context/base/mkxl/mlib-svg.lmt index 945cafbab..9dcd6984b 100644 --- a/tex/context/base/mkxl/mlib-svg.lmt +++ b/tex/context/base/mkxl/mlib-svg.lmt @@ -1327,6 +1327,26 @@ local handletransform, handleviewbox do ) )^1 + -- indeed, we need to reverse the order ... not that pretty and counter intuitive too + + local function combined() + if noftransforms == 1 then + return transforms[1] + elseif noftransforms == 2 then + return transforms[2] .. transforms[1] + elseif noftransforms == 3 then + return transforms[3] .. transforms[2] .. transforms[1] + else + -- the rare case (but anything can happen in svg and it gets worse) + local m = noftransforms + 1 + for i=1,noftransforms//2 do + local j = m - i + transforms[i], transforms[j] = transforms[j], transforms[i] + end + return concat(transforms,"",1,noftransforms) + end + end + handletransform = function(at) local t = at.transform if t then @@ -1334,7 +1354,7 @@ local handletransform, handleviewbox do lpegmatch(p_transform,t) if noftransforms > 0 then -- currentpicture - return s_transform_start, f_transform_stop(concat(transforms,"",1,noftransforms)), t + return s_transform_start, f_transform_stop(combined()), t end end end @@ -1343,7 +1363,7 @@ local handletransform, handleviewbox do if t then noftransforms = 0 lpegmatch(p_transform,t) - return noftransforms > 0 and concat(transforms,"",1,noftransforms) + return noftransforms > 0 and combined() end end diff --git a/tex/context/base/mkxl/node-ext.lmt b/tex/context/base/mkxl/node-ext.lmt index 896dd8f99..fa15b9d19 100644 --- a/tex/context/base/mkxl/node-ext.lmt +++ b/tex/context/base/mkxl/node-ext.lmt @@ -619,7 +619,7 @@ do end, } - -- why ... + -- so we have them defined and can use them at the tex end .. still needed? local open_command = get(token.create("openout")) local write_command = get(token.create("write")) diff --git a/tex/context/base/mkxl/back-ext.mkxl b/tex/context/base/mkxl/node-ext.mkxl index 4fae3d54e..697bb7d29 100644 --- a/tex/context/base/mkxl/back-ext.mkxl +++ b/tex/context/base/mkxl/node-ext.mkxl @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -% \registerctxluafile{back-ext}{autosuffix} +\registerctxluafile{node-ext}{autosuffix} \unprotect diff --git a/tex/context/base/mkxl/node-ini.mkxl b/tex/context/base/mkxl/node-ini.mkxl index 09ac085c4..101f55c05 100644 --- a/tex/context/base/mkxl/node-ini.mkxl +++ b/tex/context/base/mkxl/node-ini.mkxl @@ -22,7 +22,6 @@ \registerctxluafile{node-met}{autosuffix} \registerctxluafile{node-nut}{autosuffix} \registerctxluafile{node-res}{autosuffix} -\registerctxluafile{node-ext}{autosuffix} %registerctxluafile{node-ppt}{} % experimental, not used so probably useless \registerctxluafile{node-aux}{autosuffix} \registerctxluafile{node-gcm}{autosuffix} @@ -37,7 +36,6 @@ \registerctxluafile{node-acc}{autosuffix} % experimental %registerctxluafile{node-prp}{} % makes no sense (yet) \registerctxluafile{node-scn}{autosuffix} -\registerctxluafile{node-syn}{autosuffix} \registerctxluafile{node-par}{autosuffix} \registerctxluafile{node-bwc}{autosuffix} % for a while diff --git a/tex/context/base/mkxl/node-pro.lmt b/tex/context/base/mkxl/node-pro.lmt index 33f501aab..e09729ace 100644 --- a/tex/context/base/mkxl/node-pro.lmt +++ b/tex/context/base/mkxl/node-pro.lmt @@ -51,6 +51,7 @@ do local prependaction = tasks.prependaction local appendaction = tasks.appendaction local enableaction = tasks.enableaction + local disableaction = tasks.disableaction trackers.register("nodes.callbacks", function(v) if not v then diff --git a/tex/context/base/mkxl/node-ref.lmt b/tex/context/base/mkxl/node-ref.lmt index 2a2bf267f..269b2e749 100644 --- a/tex/context/base/mkxl/node-ref.lmt +++ b/tex/context/base/mkxl/node-ref.lmt @@ -7,15 +7,11 @@ if not modules then modules = { } end modules ['node-ref'] = { license = "see context related readme files" } --- We supported pdf right from the start and in mkii this has resulted in --- extensive control over the links. Nowadays pdftex provides a lot more --- control over margins but as mkii supports multiple backends we stuck to --- our own mechanisms. In mkiv again we implement our own handling. Eventually --- we will even disable the pdf primitives. - --- helper, will end up in luatex - --- is grouplevel still used? +-- We supported pdf right from the start and in mkii this has resulted in extensive +-- control over the links. Nowadays pdftex provides a lot more control over margins +-- but as mkii supports multiple backends we stuck to our own mechanisms. In mkiv +-- again we implement our own handling. Eventually we will even disable the pdf +-- primitives. local tonumber = tonumber local concat = table.concat @@ -49,6 +45,16 @@ local report_area = logs.reporter("backend","areas") local texsetcount = tex.setcount ----- texsetattribute = tex.setattribute +local injectreference = backends.nodeinjections.reference +local injectdestination = backends.nodeinjections.destination +local prerollreference = backends.codeinjections.prerollreference + +updaters.register("backends.injections.latebindings",function() + injectreference = backends.nodeinjections.reference + injectdestination = backends.nodeinjections.destination + prerollreference = backends.codeinjections.prerollreference +end) + local nuts = nodes.nuts local nodepool = nuts.pool @@ -566,7 +572,7 @@ do if depth < dp then depth = dp end end -- logs.report("temp","used: ht=%p dp=%p",height,depth) - local annot = nodeinjections.reference(reference,width,height,depth,set,resolved.mesh) + local annot = injectreference(reference,width,height,depth,set,resolved.mesh) if annot then annot = tonut(annot) -- todo nofreferences = nofreferences + 1 @@ -745,7 +751,7 @@ do end end nofdestinations = nofdestinations + 1 - local annot = nodeinjections.destination(width,height,depth,name,view) + local annot = injectdestination(width,height,depth,name,view) if annot then annot = tonut(annot) -- obsolete soon if result then diff --git a/tex/context/base/mkxl/node-syn.mkxl b/tex/context/base/mkxl/node-syn.mkxl new file mode 100644 index 000000000..5dcd624d6 --- /dev/null +++ b/tex/context/base/mkxl/node-syn.mkxl @@ -0,0 +1,20 @@ +%D \module +%D [ file=node-syn, +%D version=2006.08.20, % moved to separate module +%D title=\CONTEXT\ Node Macros, +%D subtitle=Synctex, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\registerctxluafile{node-syn}{autosuffix} + +\unprotect + +%D There is nothing defined at the \TEX\ end. + +\protect \endinput diff --git a/tex/context/base/mkxl/scrn-ref.mklx b/tex/context/base/mkxl/scrn-ref.mklx index 63f76a092..d6fc6e127 100644 --- a/tex/context/base/mkxl/scrn-ref.mklx +++ b/tex/context/base/mkxl/scrn-ref.mklx @@ -20,11 +20,11 @@ \appendtoks \doifsomething{\interactionparameter\c!calculate}% {\clf_setfieldcalculationset{\interactionparameter\c!calculate}}% - \doifelse{\interactionparameter\c!click }\v!yes + \doifelse{\interactionparameter\c!click}\v!yes \settrue\setfalse\highlighthyperlinks \doifelse{\interactionparameter\c!display}\v!new \settrue\setfalse\gotonewwindow - \doifnot {\interactionparameter\c!page}\v!no + \doifnot{\interactionparameter\c!page}\v!no \scrn_reference_enable_page_destinations \to \everysetupinteraction diff --git a/tex/context/base/mkxl/strc-lst.mklx b/tex/context/base/mkxl/strc-lst.mklx index 2046be727..e01441875 100644 --- a/tex/context/base/mkxl/strc-lst.mklx +++ b/tex/context/base/mkxl/strc-lst.mklx @@ -1538,7 +1538,7 @@ %D A helper: -\def\strc_lists_limitated_text#text% +\protected\def\strc_lists_limitated_text#text% {\edef\p_maxwidth{\listparameter\c!maxwidth}% \ifempty\p_maxwidth \listparameter\c!textcommand{#text}% diff --git a/tex/context/interface/mkii/keys-en.xml b/tex/context/interface/mkii/keys-en.xml index 3496d40b5..88cd1886b 100644 --- a/tex/context/interface/mkii/keys-en.xml +++ b/tex/context/interface/mkii/keys-en.xml @@ -82,6 +82,7 @@ <cd:variable name='anchor' value='anchor'/> <cd:variable name='and' value='and'/> <cd:variable name='answerarea' value='answerarea'/> + <cd:variable name='append' value='append'/> <cd:variable name='appendices' value='appendices'/> <cd:variable name='appendix' value='appendix'/> <cd:variable name='april' value='april'/> @@ -153,6 +154,7 @@ <cd:variable name='commands' value='commands'/> <cd:variable name='comment' value='comment'/> <cd:variable name='component' value='component'/> + <cd:variable name='compress' value='compress'/> <cd:variable name='compressseparator' value='compressseparator'/> <cd:variable name='compressstopper' value='compressstopper'/> <cd:variable name='concept' value='concept'/> @@ -189,6 +191,7 @@ <cd:variable name='enumeration' value='enumeration'/> <cd:variable name='environment' value='environment'/> <cd:variable name='even' value='even'/> + <cd:variable name='explicit' value='explicit'/> <cd:variable name='export' value='export'/> <cd:variable name='external' value='external'/> <cd:variable name='extremestretch' value='extremestretch'/> @@ -439,6 +442,7 @@ <cd:variable name='postscript' value='postscript'/> <cd:variable name='precedingpage' value='precedingpage'/> <cd:variable name='preference' value='preference'/> + <cd:variable name='prepend' value='prepend'/> <cd:variable name='preview' value='preview'/> <cd:variable name='previous' value='previous'/> <cd:variable name='previousevenpage' value='previousevenpage'/> @@ -1376,6 +1380,7 @@ <cd:element name='load' value='load'/> <cd:element name='local' value='local'/> <cd:element name='makeup' value='makeup'/> + <cd:element name='namednotation' value='namednotation'/> <cd:element name='namedtyping' value='namedtyping'/> <cd:element name='next' value='next'/> <cd:element name='place' value='place'/> @@ -1548,6 +1553,7 @@ <cd:command name='definereferencelist' value='definereferencelist'/> <cd:command name='defineregister' value='defineregister'/> <cd:command name='definerule' value='definerule'/> + <cd:command name='definesavebuffer' value='startsavebuffer'/> <cd:command name='definesection' value='definesection'/> <cd:command name='definesectionblock' value='definesectionblock'/> <cd:command name='definesorting' value='definesorting'/> @@ -1724,6 +1730,9 @@ <cd:command name='moveformula' value='moveformula'/> <cd:command name='moveongrid' value='moveongrid'/> <cd:command name='movesidefloat' value='movesidefloat'/> + <cd:command name='namedconstruction' value='namedconstruction'/> + <cd:command name='nameddescription' value='nameddescription'/> + <cd:command name='namedenumeration' value='namedenumeration'/> <cd:command name='navigating' value='navigating'/> <cd:command name='nodimension' value='nodimension'/> <cd:command name='noheaderandfooterlines' value='noheaderandfooterlines'/> @@ -2095,6 +2104,13 @@ <cd:command name='startmakeup' value='startmakeup'/> <cd:command name='startmarginblock' value='startmarginblock'/> <cd:command name='startmarginrule' value='startmarginrule'/> + <cd:command name='startnamedconstruction' value='startnamedconstruction'/> + <cd:command name='startnameddescription' value='startnameddescription'/> + <cd:command name='startnamedenumeration' value='startnamedenumeration'/> + <cd:command name='startnamedmatrix' value='startnamedmatrix'/> + <cd:command name='startnamedsection' value='startnamedsection'/> + <cd:command name='startnamedsubformulas' value='startnamedsubformulas'/> + <cd:command name='startnamedtyping' value='startnamedtyping'/> <cd:command name='startnarrower' value='startnarrower'/> <cd:command name='startopposite' value='startopposite'/> <cd:command name='startoverlay' value='startoverlay'/> @@ -2138,6 +2154,13 @@ <cd:command name='stopmakeup' value='stopmakeup'/> <cd:command name='stopmarginblock' value='stopmarginblock'/> <cd:command name='stopmarginrule' value='stopmarginrule'/> + <cd:command name='stopnamedconstruction' value='stopnamedconstruction'/> + <cd:command name='stopnameddescription' value='stopnameddescription'/> + <cd:command name='stopnamedenumeration' value='stopnamedenumeration'/> + <cd:command name='stopnamedmatrix' value='stopnamedmatrix'/> + <cd:command name='stopnamedsection' value='stopnamedsection'/> + <cd:command name='stopnamedsubformulas' value='stopnamedsubformulas'/> + <cd:command name='stopnamedtyping' value='stopnamedtyping'/> <cd:command name='stopnarrower' value='stopnarrower'/> <cd:command name='stopopposite' value='stopopposite'/> <cd:command name='stopoverlay' value='stopoverlay'/> diff --git a/tex/context/interface/mkii/keys-fr.xml b/tex/context/interface/mkii/keys-fr.xml index 0149da566..9dd507c6a 100644 --- a/tex/context/interface/mkii/keys-fr.xml +++ b/tex/context/interface/mkii/keys-fr.xml @@ -191,6 +191,7 @@ <cd:variable name='enumeration' value='énumération'/> <cd:variable name='environment' value='environnement'/> <cd:variable name='even' value='paire'/> + <cd:variable name='explicit' value='explicit'/> <cd:variable name='export' value='exporter'/> <cd:variable name='external' value='externe'/> <cd:variable name='extremestretch' value='etirementextreme'/> diff --git a/tex/context/modules/mkxl/m-openstreetmap.lmt b/tex/context/modules/mkxl/m-openstreetmap.lmt index 39a1d34d4..c8c6b4234 100644 --- a/tex/context/modules/mkxl/m-openstreetmap.lmt +++ b/tex/context/modules/mkxl/m-openstreetmap.lmt @@ -326,6 +326,7 @@ local colors = { water = true, wetland = true, wood = true, + fault = true, }, barrier = { chain = true, @@ -483,7 +484,7 @@ local forcedlines = { historic = { "citywalls" }, leisure = { "track", "slipway" }, man_made = { "breakwater", "cutline", "embankment", "groyne", "pipeline" }, - natural = { "cliff", "earth_bank", "tree_row", "ridge", "arete" }, + natural = { "cliff", "earth_bank", "tree_row", "ridge", "arete", "fault" }, power = { "cable", "line", "minor_line" }, tourism = { "yes"}, waterway = { "canal", "derelict_canal", "ditch", "drain", "river", "stream", "tidal_channel", "wadi", "weir" }, diff --git a/tex/context/modules/mkxl/m-openstreetmap.mkxl b/tex/context/modules/mkxl/m-openstreetmap.mkxl index 29cf8eada..260734780 100644 --- a/tex/context/modules/mkxl/m-openstreetmap.mkxl +++ b/tex/context/modules/mkxl/m-openstreetmap.mkxl @@ -100,31 +100,31 @@ \definecolor[osm:amenity:university] [osm:university] % what color ... (obscures buildings) -\definecolor[osm-amenity:bank] [osm:building:special] -\definecolor[osm-amenity:bicycle_parking] [osm:building:special] -\definecolor[osm-amenity:bicycle_repair_station] [osm:building:special] -\definecolor[osm-amenity:cafe] [osm:building:special] -\definecolor[osm-amenity:car_wash] [osm:building:special] -\definecolor[osm-amenity:childcare] [osm:building:special] -\definecolor[osm-amenity:clinic] [osm:building:special] -\definecolor[osm-amenity:clubhouse] [osm:building:special] -\definecolor[osm-amenity:college] [osm:building:special] -\definecolor[osm-amenity:community_centre] [osm:building:special] -\definecolor[osm-amenity:computer_lab] [osm:building:special] -\definecolor[osm-amenity:events_venue] [osm:building:special] -\definecolor[osm-amenity:fast_food] [osm:building:special] -\definecolor[osm-amenity:fire_station] [osm:building:special] -\definecolor[osm-amenity:fountain] [osm:building:special] -\definecolor[osm-amenity:fuel] [osm:building:special] -\definecolor[osm-amenity:library] [osm:building:special] -\definecolor[osm-amenity:mailroom] [osm:building:special] -\definecolor[osm-amenity:pharmacy] [osm:building:special] -\definecolor[osm-amenity:place_of_worship] [osm:building:special] -\definecolor[osm-amenity:post_office] [osm:building:special] -\definecolor[osm-amenity:recycling] [osm:building:special] -\definecolor[osm-amenity:research_institute] [osm:building:special] -\definecolor[osm-amenity:theatre] [osm:building:special] -\definecolor[osm-amenity:wellness_centre] [osm:building:special] +\definecolor[osm:amenity:bank] [osm:building:special] +\definecolor[osm:amenity:bicycle_parking] [osm:building:special] +\definecolor[osm:amenity:bicycle_repair_station] [osm:building:special] +\definecolor[osm:amenity:cafe] [osm:building:special] +\definecolor[osm:amenity:car_wash] [osm:building:special] +\definecolor[osm:amenity:childcare] [osm:building:special] +\definecolor[osm:amenity:clinic] [osm:building:special] +\definecolor[osm:amenity:clubhouse] [osm:building:special] +\definecolor[osm:amenity:college] [osm:building:special] +\definecolor[osm:amenity:community_centre] [osm:building:special] +\definecolor[osm:amenity:computer_lab] [osm:building:special] +\definecolor[osm:amenity:events_venue] [osm:building:special] +\definecolor[osm:amenity:fast_food] [osm:building:special] +\definecolor[osm:amenity:fire_station] [osm:building:special] +\definecolor[osm:amenity:fountain] [osm:building:special] +\definecolor[osm:amenity:fuel] [osm:building:special] +\definecolor[osm:amenity:library] [osm:building:special] +\definecolor[osm:amenity:mailroom] [osm:building:special] +\definecolor[osm:amenity:pharmacy] [osm:building:special] +\definecolor[osm:amenity:place_of_worship] [osm:building:special] +\definecolor[osm:amenity:post_office] [osm:building:special] +\definecolor[osm:amenity:recycling] [osm:building:special] +\definecolor[osm:amenity:research_institute] [osm:building:special] +\definecolor[osm:amenity:theatre] [osm:building:special] +\definecolor[osm:amenity:wellness_centre] [osm:building:special] \definecolor[osm:area:yes] [osm:unknown] diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 05dfc4b94..c531fcd64 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2021-10-15 13:57 +-- merge date : 2021-10-18 23:11 do -- begin closure to overcome local limits and interference |