From 9e2c13b12ff90635be145c6c02e21d6e9583037f Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Wed, 19 Oct 2016 23:19:58 +0200 Subject: 2016-10-19 22:59:00 --- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkiv/anch-pgr.lua | 2 +- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/grph-inc.lua | 15 +- tex/context/base/mkiv/lpdf-fmt.lua | 18 ++ tex/context/base/mkiv/lpdf-pda.xml | 259 +++++++++--------- tex/context/base/mkiv/lpdf-xmp.lua | 29 +- tex/context/base/mkiv/math-ini.mkiv | 6 +- tex/context/base/mkiv/meta-imp-txt.mkiv | 299 ++++++++++++++++----- tex/context/base/mkiv/page-txt.mkvi | 193 ++++--------- tex/context/base/mkiv/spac-hor.mkiv | 2 +- tex/context/base/mkiv/status-files.pdf | Bin 21187 -> 21188 bytes tex/context/base/mkiv/status-lua.pdf | Bin 368311 -> 368426 bytes tex/context/base/mkiv/strc-mat.mkiv | 6 +- tex/context/base/mkiv/strc-pag.mkiv | 8 +- tex/context/base/mkiv/util-fil.lua | 26 +- tex/context/base/mkiv/util-sac.lua | 32 ++- tex/context/base/mkiv/util-sql-imp-client.lua | 21 +- tex/context/base/mkiv/util-sql-imp-library.lua | 2 +- tex/context/base/mkiv/util-sql-imp-swiglib.lua | 2 +- tex/context/base/mkiv/util-sql-tickets.lua | 3 +- tex/context/base/mkiv/util-sql.lua | 11 +- tex/context/interface/mkiv/i-context.pdf | Bin 839724 -> 836178 bytes tex/context/interface/mkiv/i-floats.xml | 39 +-- tex/context/interface/mkiv/i-readme.pdf | Bin 60763 -> 60767 bytes tex/context/modules/mkiv/m-educat.mkiv | 8 +- tex/context/modules/mkiv/m-scite.mkiv | 31 ++- .../modules/mkiv/s-languages-frequencies.lua | 4 + tex/context/modules/mkiv/x-setups-basics.mkiv | 109 +++++++- tex/context/modules/mkiv/x-setups-proofing.mkiv | 5 +- tex/context/test/mkiv/pdf-a2a.mkiv | 40 +++ tex/context/test/mkiv/pdf-a3a.mkiv | 43 +++ tex/generic/context/luatex/luatex-fonts-merged.lua | 26 +- 35 files changed, 778 insertions(+), 469 deletions(-) create mode 100644 tex/context/test/mkiv/pdf-a2a.mkiv create mode 100644 tex/context/test/mkiv/pdf-a3a.mkiv (limited to 'tex') diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index da1efb7aa..83368da12 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{2016.10.14 17:19} +\newcontextversion{2016.10.19 22:51} %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 7ea28a1a0..d7a057bd1 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{2016.10.14 17:19} +\edef\contextversion{2016.10.19 22:51} %D For those who want to use this: diff --git a/tex/context/base/mkiv/anch-pgr.lua b/tex/context/base/mkiv/anch-pgr.lua index 22b52af66..fa5d50de8 100644 --- a/tex/context/base/mkiv/anch-pgr.lua +++ b/tex/context/base/mkiv/anch-pgr.lua @@ -676,7 +676,7 @@ implement { end end else - print("\n missing",tag) + -- print("\n missing",tag) end end context(f_template_a(nofboxes,list)) diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 2d14d1b1f..60d157f8a 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2016.10.14 17:19} +\newcontextversion{2016.10.19 22:51} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 7a959952f..f134fac64 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.10.14 17:19} +\edef\contextversion{2016.10.19 22:51} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua index a58e1bbce..e9bf17bf0 100644 --- a/tex/context/base/mkiv/grph-inc.lua +++ b/tex/context/base/mkiv/grph-inc.lua @@ -1163,12 +1163,14 @@ end function figures.identify(data) data = data or callstack[#callstack] or lastfiguredata - local list = identifiers.list -- defined at the end - 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 - break + if data then + local list = identifiers.list -- defined at the end + 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 + break + end end end return data @@ -1320,7 +1322,6 @@ local function checktransform(figure,forced) if auto_transform then local orientation = (forced ~= "" and forced ~= v_auto and forced) or figure.orientation or 0 local transform = transforms["orientation-"..orientation] - print(orientation,figure.orientation,transform) figure.transform = transform if math.odd(transform) then return figure.height, figure.width diff --git a/tex/context/base/mkiv/lpdf-fmt.lua b/tex/context/base/mkiv/lpdf-fmt.lua index 62b7eb91e..8bbd3374f 100644 --- a/tex/context/base/mkiv/lpdf-fmt.lua +++ b/tex/context/base/mkiv/lpdf-fmt.lua @@ -114,6 +114,7 @@ local formats = utilities.storage.allocate { transparency = true, -- todo: block at lua level jbig2_compression = true, -- todo: block at lua level jpeg2000_compression = true, -- todo: block at lua level + include_cidsets = true, inject_metadata = function() -- nothing end @@ -128,6 +129,7 @@ local formats = utilities.storage.allocate { cmyk_colors = true, spot_colors = true, internal_icc_profiles = true, + include_cidsets = true, inject_metadata = function() addtoinfo("GTS_PDFXVersion","PDF/X-1a:2001") injectxmpinfo("xml://rdf:RDF","PDF/X-1a:2001",false) @@ -142,6 +144,7 @@ local formats = utilities.storage.allocate { cmyk_colors = true, spot_colors = true, internal_icc_profiles = true, + include_cidsets = true, inject_metadata = function() addtoinfo("GTS_PDFXVersion","PDF/X-1a:2003") injectxmpinfo("xml://rdf:RDF","PDF/X-1a:2003",false) @@ -160,6 +163,7 @@ local formats = utilities.storage.allocate { cielab_colors = true, internal_icc_profiles = true, include_intents = true, + include_cidsets = true, inject_metadata = function() addtoinfo("GTS_PDFXVersion","PDF/X-3:2002") end @@ -178,6 +182,7 @@ local formats = utilities.storage.allocate { internal_icc_profiles = true, include_intents = true, jbig2_compression = true, + include_cidsets = true, inject_metadata = function() addtoinfo("GTS_PDFXVersion","PDF/X-3:2003") end @@ -200,6 +205,7 @@ local formats = utilities.storage.allocate { jbig2_compression = true, jpeg2000_compression = true, object_compression = true, + include_cidsets = true, inject_metadata = function() injectxmpinfo("xml://rdf:RDF","PDF/X-4",false) insertxmpinfo("xml://rdf:Description/xmpMM:InstanceID","1",false) @@ -225,6 +231,7 @@ local formats = utilities.storage.allocate { jbig2_compression = true, jpeg2000_compression = true, object_compression = true, + include_cidsets = true, inject_metadata = function() injectxmpinfo("xml://rdf:RDF","PDF/X-4p",false) insertxmpinfo("xml://rdf:Description/xmpMM:InstanceID","1",false) @@ -250,6 +257,7 @@ local formats = utilities.storage.allocate { jbig2_compression = true, jpeg2000_compression = true, object_compression = true, + include_cidsets = true, inject_metadata = function() -- todo end @@ -274,6 +282,7 @@ local formats = utilities.storage.allocate { jbig2_compression = true, jpeg2000_compression = true, object_compression = true, + include_cidsets = true, inject_metadata = function() -- todo end @@ -297,6 +306,7 @@ local formats = utilities.storage.allocate { jpeg2000_compression = true, nchannel_colorspace = true, object_compression = true, + include_cidsets = true, inject_metadata = function() -- todo end @@ -316,6 +326,7 @@ local formats = utilities.storage.allocate { forms = true, -- NEW; forms are allowed (with limitations); no JS, other restrictions are unknown (TODO) tagging = true, -- NEW; the only difference to PDF/A-1b internal_icc_profiles = true, + include_cidsets = true, inject_metadata = function() injectxmpinfo("xml://rdf:RDF","1A",false) end @@ -334,6 +345,7 @@ local formats = utilities.storage.allocate { include_intents = true, forms = true, internal_icc_profiles = true, + include_cidsets = true, inject_metadata = function() injectxmpinfo("xml://rdf:RDF","1B",false) end @@ -357,6 +369,7 @@ local formats = utilities.storage.allocate { jbig2_compression = true, jpeg2000_compression = true, -- NEW object_compression = true, + include_cidsets = false, inject_metadata = function() injectxmpinfo("xml://rdf:RDF","2A",false) end @@ -380,6 +393,7 @@ local formats = utilities.storage.allocate { jbig2_compression = true, jpeg2000_compression = true, object_compression = true, + include_cidsets = false, inject_metadata = function() injectxmpinfo("xml://rdf:RDF","3A",false) end @@ -402,6 +416,7 @@ local formats = utilities.storage.allocate { jbig2_compression = true, jpeg2000_compression = true, object_compression = true, + include_cidsets = true, inject_metadata = function() injectxmpinfo("xml://rdf:RDF","3A",false) injectxmpinfo("xml://rdf:RDF","1",false) @@ -738,6 +753,9 @@ function codeinjections.setformat(s) report_backend("forcing pdf version %s.%s, compression disabled", majorversion,minorversion) end + if pdf.setomitcidset then + pdf.setomitcidset(formatspecification.include_cidsets == false and 1 or 0) + end -- -- context.setupcolors { -- not this way -- cmyk = spec.cmyk_colors and variables.yes or variables.no, diff --git a/tex/context/base/mkiv/lpdf-pda.xml b/tex/context/base/mkiv/lpdf-pda.xml index 3f6b969c0..78ad47f21 100644 --- a/tex/context/base/mkiv/lpdf-pda.xml +++ b/tex/context/base/mkiv/lpdf-pda.xml @@ -50,127 +50,142 @@ xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/" xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#" xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#"> - - - - http://ns.adobe.com/pdf/1.3/ - pdf - Adobe PDF Schema - - - - internal - A name object indicating whether the document has been modified to include trapping information - Trapped - Text - - - - - - http://purl.org/dc/elements/1.1/ - pdf - Dubline Core Schema - - - - internal - Subject in Document Properties - description - Text - - - - - - http://ns.adobe.com/pdfx/1.3/ - pdfx - PDF/X ID Schema - - - - external - Name of the ConTeXt job - ConTeXt.Jobname - Text - - - external - Time stamp of ConTeXt version - ConTeXt.Time - Text - - - external - ConTeXt website - ConTeXt.Url - Text - - - external - ConTeXt version - ConTeXt.Version - Text - - - external - Banner of pdftex or one of its successors - PTEX.Fullbanner - Text - - - external - Document identifier - ID - Text - - - - - - http://ns.adobe.com/xap/1.0/mm/ - xmpMM - XMP Media Management Schema - - - - internal - UUID based identifier for specific incarnation of a document - InstanceID - URI - - - - - - http://www.aiim.org/pdfa/ns/id/ - pdfaid - PDF/A ID Schema - - - - internal - Part of PDF/A standard - part - Integer - - - internal - Amendment of PDF/A standard - amd - Text - - - internal - Conformance level of PDF/A standard - conformance - Text - - - - - - - + + + + http://ns.adobe.com/pdf/1.3/ + pdf + Adobe PDF Schema + + + + internal + A name object indicating whether the document has been modified to include trapping information + Trapped + Text + + + + + + + + + http://purl.org/dc/elements/1.1/ + pdf + Dubline Core Schema + + + + internal + Subject in Document Properties + description + Text + + + + + + + + + http://ns.adobe.com/pdfx/1.3/ + pdfx + PDF/X ID Schema + + + + external + Name of the ConTeXt job + ConTeXt.Jobname + Text + + + external + Time stamp of ConTeXt version + ConTeXt.Time + Text + + + external + ConTeXt website + ConTeXt.Url + Text + + + external + ConTeXt version + ConTeXt.Version + Text + + + external + Banner of pdftex or one of its successors + PTEX.Fullbanner + Text + + + external + Document identifier + ID + Text + + + + + + + + + http://ns.adobe.com/xap/1.0/mm/ + xmpMM + XMP Media Management Schema + + + + internal + UUID based identifier for specific incarnation of a document + InstanceID + URI + + + + + + + + + http://www.aiim.org/pdfa/ns/id/ + pdfaid + PDF/A ID Schema + + + + internal + Part of PDF/A standard + part + Integer + + + internal + Amendment of PDF/A standard + amd + Text + + + internal + Conformance level of PDF/A standard + conformance + Text + + + + + + + + + + diff --git a/tex/context/base/mkiv/lpdf-xmp.lua b/tex/context/base/mkiv/lpdf-xmp.lua index e63dfa2e0..a514d5655 100644 --- a/tex/context/base/mkiv/lpdf-xmp.lua +++ b/tex/context/base/mkiv/lpdf-xmp.lua @@ -8,7 +8,8 @@ if not modules then modules = { } end modules ['lpdf-xmp'] = { } local tostring, type = tostring, type -local format, random, char, gsub, concat = string.format, math.random, string.char, string.gsub, table.concat +local format, gsub = string.format, string.gsub +local utfchar = utf.char local xmlfillin = xml.fillin local trace_xmp = false trackers.register("backend.xmp", function(v) trace_xmp = v end) @@ -26,14 +27,15 @@ local pdfconstant = lpdf.constant local pdfreference = lpdf.reference local pdfflushstreamobject = lpdf.flushstreamobject --- I wonder why this begin end is empty / w (no time now to look into it) / begin can also be "?" +-- The XMP packet wrapper is kind of fixed, see page 10 of XMPSpecificationsPart1.pdf from +-- XMP-Toolkit-SDK-CC201607.zip. So we hardcode the id. -local xpacket = [[ - +local xpacket = format ( [[ + -%s +%%s -]] +]], utfchar(0xFEFF), utfchar(0x0089) ) local mapping = { -- user defined keys (pdfx:) @@ -239,25 +241,13 @@ end -- flushing -local function randomstring(n) - local t = { } - for i=1,n do - t[i] = char(96 + random(26)) - end - return concat(t) -end - -randomstring(26) -- kind of initializes and kicks off random - local function flushxmpinfo() commands.pushrandomseed() commands.setrandomseed(os.time()) - local version = status.luatex_version local revision = status.luatex_revision - local packetid = "no unique packet id here" -- 24 chars local documentid = "no unique document id here" local instanceid = "no unique instance id here" local producer = format("LuaTeX-%i.%i.%s",math.div(version,100),math.mod(version,100),revision) @@ -266,7 +256,6 @@ local function flushxmpinfo() local fullbanner = status.banner if included.id ~= "fake" then - packetid = randomstring(24) documentid = "uuid:" .. os.uuid() instanceid = "uuid:" .. os.uuid() end @@ -301,7 +290,7 @@ local function flushxmpinfo() report_xmp("stop xmp blob") logs.poptarget() end - blob = format(xpacket,packetid,blob) + blob = format(xpacket,blob) if not verbose and pdf.getcompresslevel() > 0 then blob = gsub(blob,">%s+<","><") end diff --git a/tex/context/base/mkiv/math-ini.mkiv b/tex/context/base/mkiv/math-ini.mkiv index bd8a28762..773e77536 100644 --- a/tex/context/base/mkiv/math-ini.mkiv +++ b/tex/context/base/mkiv/math-ini.mkiv @@ -137,10 +137,12 @@ \unexpanded\def\startforceddisplaymath {\startimath \displaystyle + \begingroup \settrue\indisplaymath} \unexpanded\def\stopforceddisplaymath - {\stopimath} + {\endgroup + \stopimath} % \unexpanded\def\rawmathcharacter#1% slow but only for tracing % {\begingroup @@ -2474,7 +2476,7 @@ \else \zerocount \fi - \mathrulesfam\fam\textstyle + \mathrulesfam\zerocount \to \everymathematics \protect \endinput diff --git a/tex/context/base/mkiv/meta-imp-txt.mkiv b/tex/context/base/mkiv/meta-imp-txt.mkiv index ae616ddb2..1ce847f67 100644 --- a/tex/context/base/mkiv/meta-imp-txt.mkiv +++ b/tex/context/base/mkiv/meta-imp-txt.mkiv @@ -150,84 +150,239 @@ \setupshapetexts [\c!bodyfont=] -%%%%%%% rotfont nog definieren - \doifundefined{RotFont}{\definefont[RotFont][RegularBold*default]} -\unexpanded\def\processfollowingtoken#1% strut toegevoegd - {\appendtoks#1\to\MPtoks - \setbox\MPbox=\hbox{\RotFont\setstrut\strut\the\MPtoks}% - \startMPdrawing - n := n + 1 ; len[n] := \the\wd\MPbox ; - \stopMPdrawing - \startMPdrawing[-] - % pic[n] := textext{\RotFont\setstrut\strut#1} ; % btex \RotFont\setstrut\strut#1 etex ; - pic[n] := btex \RotFont\setstrut\strut#1 etex ; - pic[n] := pic[n] shifted - llcorner pic[n] ; - \stopMPdrawing} - -\startuseMPgraphic{followtokens} - % we default to nothing -\stopuseMPgraphic +% \startuseMPgraphic{followtokens} +% % we default to nothing +% \stopuseMPgraphic + +% \unexpanded\def\processfollowingtoken#1% strut toegevoegd +% {\appendtoks#1\to\MPtoks +% \setbox\MPbox=\hbox{\RotFont\setstrut\strut\the\MPtoks}% +% \startMPdrawing +% n := n + 1 ; len[n] := \the\wd\MPbox ; +% \stopMPdrawing +% \startMPdrawing[-] +% % pic[n] := textext{\RotFont\setstrut\strut#1} ; % btex \RotFont\setstrut\strut#1 etex ; +% pic[n] := btex \RotFont\setstrut\strut#1 etex ; +% pic[n] := pic[n] shifted - llcorner pic[n] ; +% \stopMPdrawing} +% +% \unexpanded\def\dofollowtokens#1#2% +% {\vbox\bgroup +% \forgetall +% \dontcomplain +% \doifundefined{RotFont}{\definefont[RotFont][RegularBold*default]}% +% \MPtoks\emptytoks +% \resetMPdrawing +% \startMPdrawing +% \includeMPgraphic{followtokens} ; +% picture pic[] ; numeric len[], n ; n := 0 ; +% \stopMPdrawing +% \handletokens#2\with\processfollowingtoken +% \startMPdrawing +% if unknown RotPath : path RotPath ; RotPath := origin ; fi ; +% if unknown RotColor : color RotColor ; RotColor := black ; fi ; +% if unknown TraceRot : boolean TraceRot ; TraceRot := false ; fi ; +% if unknown ExtraRot : numeric ExtraRot ; ExtraRot := 0 ; fi ; +% numeric al, at, pl, pc, wid, pos ; pair ap, ad ; +% al := arclength RotPath ; +% if al=0 : +% al := len[n] + ExtraRot ; +% RotPath := origin -- (al,0) ; +% fi ; +% if al1 : (n-1) else : 1 fi) ; +% pc := 0 ; +% else : % centered / MP +% pl := 0 ; +% pc := arclength RotPath/2 - len[n]/2 ; +% fi ; +% if TraceRot : +% draw RotPath withpen pencircle scaled 1pt withcolor blue ; +% fi ; +% for i=1 upto n : +% wid := abs(xpart urcorner pic[i] - xpart llcorner pic[i]) ; +% pos := len[i]-wid/2 + (i-1)*pl + pc ; +% at := arctime pos of RotPath ; +% ap := point at of RotPath ; +% ad := direction at of RotPath ; +% draw pic[i] shifted (-wid/2,0) rotated(angle(ad)) shifted ap +% withcolor RotColor ; +% if TraceRot : +% draw boundingbox +% pic[i] shifted (-wid/2,0) rotated(angle(ad)) shifted ap +% withpen pencircle scaled .25pt withcolor red ; +% draw ap +% withpen pencircle scaled .50pt withcolor green ; +% fi ; +% endfor ; +% \stopMPdrawing +% \MPdrawingdonetrue +% \getMPdrawing +% \resetMPdrawing +% \egroup} + +\unexpanded\def\getfollowtoken#1% + {\hbox\bgroup + \strut + \ctxlua{mp.follow_text(#1)}% + \egroup} + +\definefontfeature[mp:tp][liga=no] + +\startMPdefinitions + def mfun_follow_draw (expr alternative) = + if unknown RotPath : path RotPath ; RotPath := origin ; fi ; + % if unknown RotColor : color RotColor ; RotColor := black ; fi ; + if unknown TraceRot : boolean TraceRot ; TraceRot := false ; fi ; + if unknown ExtraRot : numeric ExtraRot ; ExtraRot := 0 ; fi ; + picture pic[] ; + numeric len[] ; len[0] := 0 ; + numeric n ; n := lua.mp.follow_size() ; + for i=1 upto n : + pic[i] := lua.mp.follow_slot(i) ; + pic[i] := pic[i] shifted - llcorner pic[i] ; + len[i] := len[i-1] + lua.mp.follow_width(i) ; + endfor ; + numeric al, at, pl, pc, wid, pos ; pair ap, ad ; + al := arclength RotPath ; + if al = 0 : + al := len[n] + ExtraRot ; + RotPath := origin -- (al,0) ; + fi ; + if al < len[n]: + RotPath := RotPath scaled ((len[n]+ExtraRot)/al) ; + al := arclength RotPath ; + fi ; + if alternative = 1 : + pl := (al-len[n])/(if n>1 : (n-1) else : 1 fi) ; + pc := 0 ; + else : % centered / MP + pl := 0 ; + pc := arclength RotPath/2 - len[n]/2 ; + fi ; + if TraceRot : + draw RotPath withpen pencircle scaled 1pt withcolor blue ; + fi ; + for i=1 upto n : + % wid := abs(xpart urcorner pic[i] - xpart llcorner pic[i]) ; + wid := lua.mp.follow_width(i) ; + pos := len[i]-wid/2 + (i-1)*pl + pc ; + at := arctime pos of RotPath ; + ap := point at of RotPath ; + ad := direction at of RotPath ; + if mfun_trial_run : + % skip (ok, somewhat inefficient as we can consider a + % dedicated store and textext variant (todo) + else : + pic[i] := pic[i] shifted (-wid/2,0) rotated(angle(ad)) shifted ap ; + draw pic[i] ; % withcolor RotColor ; + if TraceRot : + draw boundingbox pic[i] withpen pencircle scaled .25pt withcolor red ; + draw ap withpen pencircle scaled .50pt withcolor green ; + fi ; + fi ; + endfor ; + enddef ; +\stopMPdefinitions + +\startluacode + local nodecodes = nodes.nodecodes + + local visible_code = { + [nodecodes.glyph] = true, + [nodecodes.glue] = true, + [nodecodes.hlist] = true, + [nodecodes.vlist] = true, + [nodecodes.rule] = true, + } + + local disc_code = nodecodes.disc + local kern_code = nodecodes.kern + + local c_userkern = nodes.kerncodes.userkern + local a_fontkern = attributes.private("fontkern") + + local n = nil + local s = 0 + + function mp.follow_reset() + r = nil + s = 0 + end + + function mp.follow_initialize(b) + if not r then + local l = tex.takebox(b).list + n = { } + s = 0 + while l do + local c = l + l = l.next + local id = c.id + if visible_code[id] then + s = s + 1 + n[s] = c + c.prev = nil + c.next = nil + elseif id == kern_code then + if c.subtype == c_userkern and not c[a_fontkern] then + s = s + 1 + n[s] = c + c.prev = nil + else + n[s].next = c + c.prev = n[s] + end + c.next = nil + elseif id == disc_code then + local r = c.replace + while r do + s = s + 1 + n[s] = r + r = r.next + r.prev = nil + r.next = nil + end + end + end + end + end + + function mp.follow_size() + mp.print(s) + end + + function mp.follow_slot(i) + mp.print('textext("\\getfollowtoken{' .. i .. '}")') + end + + function mp.follow_text(s) + context(n[s]) + end + + function mp.follow_width(i) + mp.print(number.topoints(n[i].width)) + end +\stopluacode \unexpanded\def\dofollowtokens#1#2% {\vbox\bgroup \forgetall \dontcomplain - \doifundefined{RotFont}{\definefont[RotFont][RegularBold*default]}% - \MPtoks\emptytoks - \resetMPdrawing - \startMPdrawing + \setbox\scratchbox\hbox{\addff{mp:tp}#2}% + \ctxlua{mp.follow_initialize(\number\scratchbox)}% + \stopluacode + \startMPcode \includeMPgraphic{followtokens} ; - picture pic[] ; numeric len[], n ; n := 0 ; - \stopMPdrawing - \handletokens#2\with\processfollowingtoken - \startMPdrawing - if unknown RotPath : path RotPath ; RotPath := origin ; fi ; - if unknown RotColor : color RotColor ; RotColor := black ; fi ; - if unknown TraceRot : boolean TraceRot ; TraceRot := false ; fi ; - if unknown ExtraRot : numeric ExtraRot ; ExtraRot := 0 ; fi ; - numeric al, at, pl, pc, wid, pos ; pair ap, ad ; - al := arclength RotPath ; - if al=0 : - al := len[n] + ExtraRot ; - RotPath := origin -- (al,0) ; - fi ; - if al1 : (n-1) else : 1 fi) ; - pc := 0 ; - else : % centered / MP - pl := 0 ; - pc := arclength RotPath/2 - len[n]/2 ; - fi ; - if TraceRot : - draw RotPath withpen pencircle scaled 1pt withcolor blue ; - fi ; - for i=1 upto n : - wid := abs(xpart urcorner pic[i] - xpart llcorner pic[i]) ; - pos := len[i]-wid/2 + (i-1)*pl + pc ; - at := arctime pos of RotPath ; - ap := point at of RotPath ; - ad := direction at of RotPath ; - draw pic[i] shifted (-wid/2,0) rotated(angle(ad)) shifted ap - withcolor RotColor ; - if TraceRot : - draw boundingbox - pic[i] shifted (-wid/2,0) rotated(angle(ad)) shifted ap - withpen pencircle scaled .25pt withcolor red ; - draw ap - withpen pencircle scaled .50pt withcolor green ; - fi ; - endfor ; -% fill boundingbox currentpicture ; - \stopMPdrawing - \MPdrawingdonetrue - \getMPdrawing - \resetMPdrawing + mfun_follow_draw(\number#1) ; + \stopMPcode + \ctxlua{mp.follow_reset()}% \egroup} \unexpanded\def\followtokens {\dofollowtokens1} @@ -262,6 +417,8 @@ % \followtokenscentered{So now we have two commands.}} % \stopoverlay +% \followtokengraphicscale{6cm} +% \followtokens{Hans Hagen uses {\darkred\TeX}, {\darkgreen\Lua}, {\darkblue \MetaPost} and friends.} \startuseMPgraphic{fuzzycount} begingroup @@ -289,7 +446,7 @@ [fuzzycount] [n=10] -\def\fuzzycount#1% +\unexpanded\def\fuzzycount#1% {{\tx\useMPgraphic{fuzzycount}{n=#1}}} \defineconversion[fuzzy][\fuzzycount] diff --git a/tex/context/base/mkiv/page-txt.mkvi b/tex/context/base/mkiv/page-txt.mkvi index 515d16e13..3f0f95420 100644 --- a/tex/context/base/mkiv/page-txt.mkvi +++ b/tex/context/base/mkiv/page-txt.mkvi @@ -28,9 +28,9 @@ %D {setuptop, setupheader, setuptext, %D setupfooter, setupbottom} %D -%D The macros in this module sometimes look a bit more complicated -%D than needed, which is a direct result of the fact that their -%D ancestors are quite old and upward compatibility is a must. +%D The macros in this module sometimes look a bit more complicated than +%D needed, which is a direct result of the fact that their ancestors are +%D quite old and upward compatibility is a must. %D %D \showsetup{setuptop} %D \showsetup{setupheader} @@ -154,11 +154,10 @@ %D {setuptoptexts, setupheadertexts, setuptexttexts, %D setupfootertexts, setupbottomtexts} %D -%D The next macros take one or more arguments. The exact setup -%D depends on the number of arguments. Although not that -%D intuitive, the current scheme evolved out of the original. -%D When margin and edge texts as well as middle texts showed -%D up, the current odd|/|even scheme surfaced. +%D The next macros take one or more arguments. The exact setup depends on the number +%D of arguments. Although not that intuitive, the current scheme evolved out of the +%D original. When margin and edge texts as well as middle texts showed up, the +%D current odd|/|even scheme surfaced. %D %D \showsetup{setuptoptexts} %D \showsetup{setupheadertexts} @@ -174,80 +173,8 @@ % todo: \setuplayoutelementtext -% An alternative approach is to have more variables but that does not -% make the code less complex (probably more). - -% \unexpanded\def\page_layouts_setup_texts[#vertical][#horizontal][#a][#b][#c][#d]% -% {\ifsixthargument -% \edef\currentlayoutelement{#vertical:#horizontal}% -% \setlayoutelementparameter\c!lefttext -% {\page_layouts_process_element_double -% \c!leftstyle \c!leftcolor \c!leftwidth {#a}% -% \c!rightstyle\c!rightcolor\c!rightwidth{#d}}% -% \setlayoutelementparameter\c!righttext -% {\page_layouts_process_element_double -% \c!rightstyle\c!rightcolor\c!rightwidth{#b}% -% \c!leftstyle \c!leftcolor \c!leftwidth {#c}}% -% \else\iffifthargument -% \edef\currentlayoutelement{#vertical:\v!text}% -% \setlayoutelementparameter\c!lefttext -% {\page_layouts_process_element_double -% \c!leftstyle \c!leftcolor \c!leftwidth {#horizontal}% -% \c!rightstyle\c!rightcolor\c!rightwidth{#c}}% -% \setlayoutelementparameter\c!righttext -% {\page_layouts_process_element_double -% \c!rightstyle\c!rightcolor\c!rightwidth{#a}% -% \c!leftstyle \c!leftcolor \c!leftwidth {#b}}% -% \else\iffourthargument -% \edef\currentlayoutelement{#vertical:#horizontal}% -% \doifelsenothing{\detokenize{#a}} -% {\resetlayoutelementparameter\c!lefttext} -% {\setlayoutelementparameter\c!lefttext -% {\page_layouts_process_element_double -% \c!leftstyle\c!leftcolor\c!leftwidth{#a}% -% \c!leftstyle\c!leftcolor\c!leftwidth{#a}}}% -% \doifelsenothing{\detokenize{#b}} -% {\resetlayoutelementparameter\c!righttext} -% {\setlayoutelementparameter\c!righttext -% {\page_layouts_process_element_double -% \c!rightstyle\c!rightcolor\c!rightwidth{#b}% -% \c!rightstyle\c!rightcolor\c!rightwidth{#b}}}% -% \else\ifthirdargument -% \edef\currentlayoutelement{#vertical:\v!text}% -% \doifelsenothing{\detokenize{#horizontal}} -% {\resetlayoutelementparameter\c!lefttext} -% {\setlayoutelementparameter\c!lefttext -% {\page_layouts_process_element_double -% \c!leftstyle\c!leftcolor\c!leftwidth{#horizontal}% -% \c!leftstyle\c!leftcolor\c!leftwidth{#horizontal}}}% -% \doifelsenothing{\detokenize{#a}} -% {\resetlayoutelementparameter\c!righttext} -% {\setlayoutelementparameter\c!righttext -% {\page_layouts_process_element_double -% \c!rightstyle\c!rightcolor\c!rightwidth{#a}% -% \c!rightstyle\c!rightcolor\c!rightwidth{#a}}}% -% \else\ifsecondargument -% \edef\currentlayoutelement{#vertical:\v!text}% -% \resetlayoutelementparameter\c!lefttext -% \resetlayoutelementparameter\c!righttext -% \doifelsenothing{\detokenize{#horizontal}} -% {\resetlayoutelementparameter\c!middletext} -% {\setlayoutelementparameter\c!middletext -% {\page_layouts_process_element_single\c!style\c!color\c!width{#horizontal}}}% -% \else -% \edef\currentlayoutelement{#vertical:\v!text}% -% \resetlayoutelementparameter\c!lefttext -% \resetlayoutelementparameter\c!righttext -% \resetlayoutelementparameter\c!middletext -% \edef\currentlayoutelement{#vertical:\v!margin}% -% \resetlayoutelementparameter\c!lefttext -% \resetlayoutelementparameter\c!righttext -% \resetlayoutelementparameter\c!middletext -% \edef\currentlayoutelement{#vertical:\v!edge}% -% \resetlayoutelementparameter\c!lefttext -% \resetlayoutelementparameter\c!righttext -% \resetlayoutelementparameter\c!middletext -% \fi\fi\fi\fi\fi} +%D An alternative approach is to have more variables but that does not make the code +%D less complex (probably more). \unexpanded\def\page_layouts_setup_text_six#vertical#horizontal#a#b#c#d% {\edef\currentlayoutelement{#vertical:#horizontal}% @@ -332,8 +259,8 @@ \ifsecondargument\page_layouts_setup_text_two {#vertical}{#horizontal}\else \page_layouts_setup_text_one {#vertical}\fi\fi\fi\fi\fi} -%D Left and right texts are swapped on odd and even pages, but -%D only when double sided typesetting is enabled. +%D Left and right texts are swapped on odd and even pages, but only when double +%D sided typesetting is enabled. \unexpanded\def\page_layouts_process_element_double {\doifelseoddpage @@ -346,8 +273,7 @@ \def\page_layouts_process_element_double_even#lstyle#color#lwidth#lcontent#rstyle#rcolor#rwidth#rcontent% {\page_layouts_process_element_single#rstyle#rcolor#rwidth{#rcontent}} -%D The next macro will be cleaned up and made less messy and -%D dependent. +%D The next macro will be cleaned up and made less messy and dependent. \let\m_page_layouts_element_content\empty @@ -392,8 +318,7 @@ \setvalue{\??layouttextspecial\v!pagenumber}{\page_layouts_place_page_number} \setvalue{\??layouttextspecial\v!date }{\currentdate} -%D When specified, the texts are automatically limited in -%D length. +%D When specified, the texts are automatically limited in length. % % where used ? % @@ -417,9 +342,8 @@ \appendtoks \page_layouts_place_text_line\v!footer\footerheight \to \footertextcontent \appendtoks \page_layouts_place_text_line\v!bottom\bottomheight \to \bottomtextcontent -%D Texts can be disabled, moved up and ignored, depending in -%D the \type {status} variable. This is handled by the next -%D couple of macros. +%D Texts can be disabled, moved up and ignored, depending in the \type {status} +%D variable. This is handled by the next couple of macros. \newcount\c_page_layouts_element_state_n @@ -494,21 +418,31 @@ \page_layouts_place_text_line_indeed#vertical#height% \egroup} +% \setupheadertexts [11] +% \definetext [title] [header] [aa] +% \setupheadertexts [11] [22] +% \definetext [title] [header] [aa] [bb] +% \setupheadertexts [text] [11] [22] +% \definetext [title] [header] [text] [aa] [bb] +% \setupheadertexts [11] [22] [33] [44] +% \definetext [title] [header] [aa] [bb] [cc] [dd] +% \setupheadertexts [text] [11] [22] [33] [44] +% \definetext [title] [header] [text] [aa] [bb] [cc] [dd] + \def\page_layouts_place_text_line_unknown#vertical#height% {\global\settrue\resyncaftertextline \begingroup % new \page_layouts_reset_element_status#vertical% - \csname\namedlayoutelementhash#vertical\textlinestatus\endcsname - \csname\namedlayoutelementhash#vertical\v!text \textlinestatus\endcsname - \csname\namedlayoutelementhash#vertical\v!margin\textlinestatus\endcsname - \csname\namedlayoutelementhash#vertical\v!edge \textlinestatus\endcsname + \begincsname\namedlayoutelementhash{#vertical}\textlinestatus\endcsname + \begincsname\namedlayoutelementhash{#vertical:\v!text}\textlinestatus\endcsname + \begincsname\namedlayoutelementhash{#vertical:\v!margin}\textlinestatus\endcsname + \begincsname\namedlayoutelementhash{#vertical:\v!edge}\textlinestatus\endcsname \page_layouts_place_text_line_indeed#vertical#height% \endgroup} \letvalue{\??layouttextsline\s!unknown}\page_layouts_place_text_line_unknown -%D The following macro has to be called after a page -%D is flushed. +%D The following macro has to be called after a page is flushed. \unexpanded\def\resetlayouttextlines % public {\csname\??layouttextsreset\v!top \endcsname @@ -523,7 +457,7 @@ \fi} \def\getspecificlayouttext#vertical#horizontal#what% - {\csname\namedlayoutelementhash{#vertical:#horizontal}#what\endcsname} + {\begincsname\namedlayoutelementhash{#vertical:#horizontal}#what\endcsname} % \settext[header][text][middle][xxx][yyy] @@ -565,9 +499,8 @@ \letvalue{\??layouttextcontent\v!text:\c!left }\c!lefttext \letvalue{\??layouttextcontent\v!text:\c!right }\c!righttext -%D The placement of a whole line is handled by the next two -%D macros. These are hooked into the general purpose token -%D list registers mentioned before. +%D The placement of a whole line is handled by the next two macros. These are hooked +%D into the general purpose token list registers mentioned before. \def\page_layouts_place_text_line_indeed#vertical#height% {\let\currentlayouttextline#vertical% @@ -692,10 +625,9 @@ \hbox \layoutcomponentboxattribute to #width{#content}% \layoutelementparameter\c!after}} -%D Although it is far better to use backgrounds for this -%D purpose, one can add a rule in the following way. This -%D method makes the rules disappear in case of an empty text -%D line. Consider this a feature. +%D Although it is far better to use backgrounds for this purpose, one can add a rule +%D in the following way. This method makes the rules disappear in case of an empty +%D text line. Consider this a feature. %D %D \starttyping %D \setupheadertexts[left][right] @@ -717,14 +649,13 @@ %D \macros %D {definetext} %D -%D Some macros ago, we implemented the \type {status} option -%D \type {unknown}. This one is used to take care of -%D symbolic texts handlers. +%D Some macros ago, we implemented the \type {status} option \type {unknown}. This +%D one is used to take care of symbolic texts handlers. %D %D \showsetup{definetext} %D -%D The next example demonstrates how we can use this -%D mechanism to provide page (event) dependent text lines. +%D The next example demonstrates how we can use this mechanism to provide page +%D (event) dependent text lines. %D %D \starttyping %D \definetext[chapter][footer][pagenumber] @@ -738,24 +669,6 @@ \unexpanded\def\definetext {\doseventupleempty\page_layouts_define_text} -% \def\page_layouts_define_text[#tag][#vertical][#horizontal][#a][#b][#c][#d]% -% {\ifseventhargument -% \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}% -% {\dosixtupleempty\page_layouts_setup_texts[#vertical][#horizontal][#a][#b][#c][#d]}% -% \else\ifsixthargument -% \setvalue{\namedlayoutelementhash{#vertical}#tag}% -% {\dosixtupleempty\page_layouts_setup_texts[#vertical][#horizontal][#a][#b][#c]}% -% \else\iffifthargument -% \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}% -% {\dosixtupleempty\page_layouts_setup_texts[#vertical][#horizontal][#a][#b]}% -% \else\iffourthargument -% \setvalue{\namedlayoutelementhash{#vertical}#tag}% -% {\dosixtupleempty\page_layouts_setup_texts[#vertical][#horizontal][#a]}% -% \else -% \setvalue{\namedlayoutelementhash{#vertical}#tag}% -% {\dosixtupleempty\page_layouts_setup_texts[#vertical][#horizontal]}% -% \fi\fi\fi\fi} - \def\page_layouts_define_text[#tag][#vertical][#horizontal][#a][#b][#c][#d]% {\ifseventhargument \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}{\page_layouts_setup_text_six {#vertical}{#horizontal}{#a}{#b}{#c}{#d}}% @@ -784,8 +697,8 @@ \installpagebreakmethod \v!footer {\doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\v!footer][\c!state=\v!empty]}} -%D While the header and footer lines are moved away from the -%D main text, the top and bottom lines are centered. +%D While the header and footer lines are moved away from the main text, the top and +%D bottom lines are centered. \setuplayoutelement[\v!top ][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=] \setuplayoutelement[\v!header][\c!state=\v!normal,\c!n=0,\c!before=, \c!after=\vss,\c!strut=\v!yes] @@ -794,10 +707,10 @@ \setuplayoutelement[\v!bottom][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=] %D Moved here from strc-pag: - -% We reset a previous location but only when it has a pagenumber -% associated. This is a rather messy test but better than the MkII -% way where we use states and keep settings. +%D +%D We reset a previous location but only when it has a pagenumber associated. This +%D is a rather messy test but better than the MkII way where we use states and keep +%D settings. \let\m_page_layouts_page_number_location \relax \let\m_page_layouts_page_number_location_v\relax @@ -975,12 +888,11 @@ \smashbox\b_page_layouts_element \box\b_page_layouts_element} -%D The main text area has to be combined with some additional -%D (tracing) information. - -% will be stored as normal and overloaded in page-lyr and later in -% page-spr we overload the the stored version .. evenatually i will -% clear up the experimental mess +%D The main text area has to be combined with some additional (tracing) information. +%D +%D This will be stored as normal and overloaded in page-lyr and later in page-spr we +%D overload the the stored version .. evenatually i will clear up the experimental +%D mess. \def\settextpagecontent#1#2#3% #2 and #3 will disappear / is overloaded {\setbox#1\hbox to \makeupwidth % maybe \hpack @@ -997,4 +909,3 @@ \dp#1\zeropoint} \protect \endinput - diff --git a/tex/context/base/mkiv/spac-hor.mkiv b/tex/context/base/mkiv/spac-hor.mkiv index 111830fad..e05e0ef75 100644 --- a/tex/context/base/mkiv/spac-hor.mkiv +++ b/tex/context/base/mkiv/spac-hor.mkiv @@ -528,7 +528,7 @@ % but, since not all fonts have .5em digits: \unexpanded\def\fixedspace - {\setbox\scratchbox\hbox{\mathortext{0}{0}}% + {\setbox\scratchbox\hpack{\mathortext{0}{0}}% was \hbox \hskip\wd\scratchbox\relax} \unexpanded\def\fixedspaces diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index c60014f10..c06c1ab8a 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index 247757915..f74a63cbd 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkiv/strc-mat.mkiv b/tex/context/base/mkiv/strc-mat.mkiv index 8ff087a8c..0062948a5 100644 --- a/tex/context/base/mkiv/strc-mat.mkiv +++ b/tex/context/base/mkiv/strc-mat.mkiv @@ -829,10 +829,12 @@ \the\everydisplay % new (probably too much) \else \expandafter\startinnermath - \fi} + \fi + \begingroup} % less interference with upcoming a \over b \unexpanded\def\stopdisplaymath - {\ifcase\c_strc_formulas_mode + {\endgroup % less interference with upcoming a \over b + \ifcase\c_strc_formulas_mode \Ucheckedstopdisplaymath \or \normalUstopmath diff --git a/tex/context/base/mkiv/strc-pag.mkiv b/tex/context/base/mkiv/strc-pag.mkiv index 0a55fb45f..cf2533c46 100644 --- a/tex/context/base/mkiv/strc-pag.mkiv +++ b/tex/context/base/mkiv/strc-pag.mkiv @@ -307,12 +307,16 @@ \installdirectcommandhandler \??pagenumbering {pagenumbering} +% some day ifsinglesided and ifdoublesided will become obsolete + \appendtoks \singlesidedfalse \setfalse\layoutisdoublesided \doublesidedfalse \setfalse\layoutissinglesided + \resetsystemmode\v!singlesided + \resetsystemmode\v!doublesided \processallactionsinset[\directpagenumberingparameter\c!alternative] - [ \v!singlesided=>\singlesidedtrue\settrue\layoutissinglesided, - \v!doublesided=>\doublesidedtrue\settrue\layoutisdoublesided]% + [ \v!singlesided=>\setsystemmode\v!singlesided\singlesidedtrue\settrue\layoutissinglesided, + \v!doublesided=>\setsystemmode\v!doublesided\doublesidedtrue\settrue\layoutisdoublesided]% \ifdefined\trackingmarginnotestrue \ifdoublesided \trackingmarginnotestrue diff --git a/tex/context/base/mkiv/util-fil.lua b/tex/context/base/mkiv/util-fil.lua index eb054a5fd..0f9731a26 100644 --- a/tex/context/base/mkiv/util-fil.lua +++ b/tex/context/base/mkiv/util-fil.lua @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['util-fil'] = { local byte = string.byte local char = string.char -local extract = bit32.extract +local extract = bit32 and bit32.extract local floor = math.floor -- Here are a few helpers (the starting point were old ones I used for parsing @@ -206,17 +206,21 @@ function files.readfixed4(f) end end -function files.read2dot14(f) - local a, b = byte(f:read(2),1,2) - local n = 0x100 * a + b - local m = extract(n,0,30) - if n > 0x7FFF then - n = extract(n,30,2) - return m/0x4000 - 4 - else - n = extract(n,30,2) - return n + m/0x4000 +if extract then + + function files.read2dot14(f) + local a, b = byte(f:read(2),1,2) + local n = 0x100 * a + b + local m = extract(n,0,30) + if n > 0x7FFF then + n = extract(n,30,2) + return m/0x4000 - 4 + else + n = extract(n,30,2) + return n + m/0x4000 + end end + end function files.skipshort(f,n) diff --git a/tex/context/base/mkiv/util-sac.lua b/tex/context/base/mkiv/util-sac.lua index 8a12e7cf0..5d16be3ec 100644 --- a/tex/context/base/mkiv/util-sac.lua +++ b/tex/context/base/mkiv/util-sac.lua @@ -10,7 +10,7 @@ if not modules then modules = { } end modules ['util-sac'] = { -- with bytes) local byte, sub = string.byte, string.sub -local extract = bit32.extract +local extract = bit32 and bit32.extract utilities = utilities or { } local streams = { } @@ -177,20 +177,24 @@ function streams.readfixed4(f) end end -function streams.read2dot14(f) - local i = f[2] - local j = i + 1 - f[2] = j + 1 - local a, b = byte(f[1],i,j) - local n = 0x100 * a + b - local m = extract(n,0,30) - if n > 0x7FFF then - n = extract(n,30,2) - return m/0x4000 - 4 - else - n = extract(n,30,2) - return n + m/0x4000 +if extract then + + function streams.read2dot14(f) + local i = f[2] + local j = i + 1 + f[2] = j + 1 + local a, b = byte(f[1],i,j) + local n = 0x100 * a + b + local m = extract(n,0,30) + if n > 0x7FFF then + n = extract(n,30,2) + return m/0x4000 - 4 + else + n = extract(n,30,2) + return n + m/0x4000 + end end + end function streams.skipshort(f,n) diff --git a/tex/context/base/mkiv/util-sql-imp-client.lua b/tex/context/base/mkiv/util-sql-imp-client.lua index 55c944ebb..6a019bd3a 100644 --- a/tex/context/base/mkiv/util-sql-imp-client.lua +++ b/tex/context/base/mkiv/util-sql-imp-client.lua @@ -109,11 +109,11 @@ local function splitdata(data) -- todo: hash on first line ... maybe move to cli end end p = Cf(Ct("") * p,rawset) * newline^1 -if getserver() == "mssql" then - p = skipfirst * skipdashes * Ct(p^0) -else - p = skipfirst * Ct(p^0) -end + if getserver() == "mssql" then + p = skipfirst * skipdashes * Ct(p^0) + else + p = skipfirst * Ct(p^0) + end cache[first] = { parser = p, keys = keys } local entries = lpegmatch(p,data) return entries or { }, keys @@ -134,6 +134,11 @@ local t_runner = { mssql = [[sqlcmd -S %host% %?U: -U "%username%" ?% %?P: -P "%password%" ?% -I -W -w 65535 -s"]] .. "\t" .. [[" -m 1 -i "%queryfile%" -o "%resultfile%"]], } +local t_runner_login = { + mysql = [[mysql --login-path="%login%" --batch --database="%database%" --default-character-set=utf8 < "%queryfile%" > "%resultfile%"]], + mssql = [[sqlcmd -S %host% %?U: -U "%username%" ?% %?P: -P "%password%" ?% -I -W -w 65535 -s"]] .. "\t" .. [[" -m 1 -i "%queryfile%" -o "%resultfile%"]], +} + local t_preamble = { mysql = [[ SET GLOBAL SQL_MODE=ANSI_QUOTES; @@ -149,7 +154,7 @@ SET NOCOUNT ON; local function dataprepared(specification) local query = preparetemplate(specification) if query then - local preamble = t_preamble[getserver()] or t_preamble.mysql + local preamble = t_preamble[getserver()] or t_preamble.mysql if preamble then preamble = replacetemplate(preamble,specification.variables,'sql') query = preamble .. "\n" .. query @@ -168,7 +173,7 @@ local function dataprepared(specification) end local function datafetched(specification) - local runner = t_runner[getserver()] or t_runner.mysql + local runner = (specification.login and t_runner_login or t_runner)[getserver()] or t_runner.mysql local command = replacetemplate(runner,specification) if trace_sql then local t = osclock() @@ -227,7 +232,7 @@ local function execute(specification) return end if not datafetched(specification) then - report_state("error in fetching, query: %s",string.collapsespaces(io.loaddata(specification.queryfile))) + report_state("error in fetching, query: %s",string.collapsespaces(io.loaddata(specification.queryfile) or "?")) return end local data = dataloaded(specification) diff --git a/tex/context/base/mkiv/util-sql-imp-library.lua b/tex/context/base/mkiv/util-sql-imp-library.lua index 6dbd5a4eb..e16853612 100644 --- a/tex/context/base/mkiv/util-sql-imp-library.lua +++ b/tex/context/base/mkiv/util-sql-imp-library.lua @@ -143,7 +143,7 @@ local function fetched(specification,query,converter) local q = query[i] local r, m = connection:execute(q) if m then - report_state("error in query to host %a: %s",specification.host,string.collapsespaces(q)) + report_state("error in query to host %a: %s",specification.host,string.collapsespaces(q or "?")) if m then report_state("message: %s",m) end diff --git a/tex/context/base/mkiv/util-sql-imp-swiglib.lua b/tex/context/base/mkiv/util-sql-imp-swiglib.lua index 5ea5d7735..786b4bffc 100644 --- a/tex/context/base/mkiv/util-sql-imp-swiglib.lua +++ b/tex/context/base/mkiv/util-sql-imp-swiglib.lua @@ -436,7 +436,7 @@ local function datafetched(specification,query,converter) local q = query[i] local r, m = connection:execute(q) if m then - report_state("error in query, stage: %s",string.collapsespaces(q)) + report_state("error in query, stage: %s",string.collapsespaces(q or "?")) message = message and format("%s\n%s",message,m) or m end if type(r) == "table" then diff --git a/tex/context/base/mkiv/util-sql-tickets.lua b/tex/context/base/mkiv/util-sql-tickets.lua index a688b2ddb..f392c0b91 100644 --- a/tex/context/base/mkiv/util-sql-tickets.lua +++ b/tex/context/base/mkiv/util-sql-tickets.lua @@ -398,7 +398,8 @@ local template_cleanup_nop =[[ function tickets.cleanupdb(db,delta,nodata) -- maybe delta in db - local time = delta and (ostime() - delta) or 0 + local now = ostime() + local time = delta and (now - delta) or now local records, keys = db.execute { template = nodata and template_cleanup_nop or template_cleanup_yes, diff --git a/tex/context/base/mkiv/util-sql.lua b/tex/context/base/mkiv/util-sql.lua index a0578f086..09056c048 100644 --- a/tex/context/base/mkiv/util-sql.lua +++ b/tex/context/base/mkiv/util-sql.lua @@ -240,8 +240,9 @@ local function validspecification(specification) setmetatable(specification,defaults) end local templatefile = specification.templatefile or "query" - local queryfile = specification.queryfile or presets.queryfile or file.nameonly(templatefile) .. "-temp.sql" - local resultfile = specification.resultfile or presets.resultfile or file.nameonly(templatefile) .. "-temp.dat" + local name = file.nameonly(templatefile) + local queryfile = specification.queryfile or presets.queryfile or format("%s-temp.sql",name) + local resultfile = specification.resultfile or presets.resultfile or format("%s-temp.dat",name) specification.queryfile = queryfile specification.resultfile = resultfile if trace_sql then @@ -338,9 +339,9 @@ function sql.usedatabase(presets,datatable) local queryfile = presets.queryfile or format("%s-temp.sql",name) local resultfile = presets.resultfile or format("%s-temp.dat",name) execute = function(specification) -- variables template - if not specification.presets then specification.presets = presets end - if not specification.queryfile then specification.queryfile = queryfile end - if not specification.resultfile then specification.resultfile = queryfile end + if not specification.presets then specification.presets = presets end + if not specification.queryfile then specification.queryfile = queryfile end + if not specification.resultfile then specification.resultfile = resultfile end return m_execute(specification) end else diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index da61b5008..5751e4a9a 100644 Binary files a/tex/context/interface/mkiv/i-context.pdf and b/tex/context/interface/mkiv/i-context.pdf differ diff --git a/tex/context/interface/mkiv/i-floats.xml b/tex/context/interface/mkiv/i-floats.xml index d53956355..153078fb4 100644 --- a/tex/context/interface/mkiv/i-floats.xml +++ b/tex/context/interface/mkiv/i-floats.xml @@ -331,10 +331,13 @@ --> - + + + @@ -357,37 +360,44 @@ - - - - - + + + + + + + - + + + @@ -474,7 +484,7 @@ - - @@ -669,6 +677,7 @@ +--> diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf index d10fd15a6..ad848eedc 100644 Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ diff --git a/tex/context/modules/mkiv/m-educat.mkiv b/tex/context/modules/mkiv/m-educat.mkiv index 87a282327..e39738e99 100644 --- a/tex/context/modules/mkiv/m-educat.mkiv +++ b/tex/context/modules/mkiv/m-educat.mkiv @@ -47,7 +47,7 @@ {\begingroup \dontcomplain \setupanswerarea - [\c!n=0,\c!m=,#1,\c!location=\v!text]% + [\c!n=0,\c!m=#1,\c!location=\v!text]% \let\currenttextbackground\v!answerarea \doifelsenothing{\textbackgroundparameter\c!m} {\expandafter\donoanswerspace} @@ -158,8 +158,10 @@ #2% \getvalue{\e!stop\e!answerlines}} -\protect \doifnotmode{demo}{\endinput} - +\protect + +\continueifinputfile{m-educat.mkiv} + %D Test materiaal. \starttext diff --git a/tex/context/modules/mkiv/m-scite.mkiv b/tex/context/modules/mkiv/m-scite.mkiv index fd4a3c7a1..256a78b39 100644 --- a/tex/context/modules/mkiv/m-scite.mkiv +++ b/tex/context/modules/mkiv/m-scite.mkiv @@ -57,10 +57,10 @@ buffers.scite = scite -- context output: local f_def_color = formatters["\\definecolor[slxc%s][h=%s%s%s]%%"] -local f_fore_none = formatters["\\def\\slx%s#1{{\\slxc%s#1}}%%"] -local f_fore_bold = formatters["\\def\\slx%s#1{{\\slxc%s\\bf#1}}%%"] -local f_none_bold = formatters["\\def\\slx%s#1{{\\bf#1}}%%"] -local f_none_none = formatters["\\def\\slx%s#1{{#1}}%%"] +local f_fore_none = formatters["\\unexpanded\\def\\slx%s#1{{\\slxc%s#1}}%%"] +local f_fore_bold = formatters["\\unexpanded\\def\\slx%s#1{{\\slxc%s\\bf#1}}%%"] +local f_none_bold = formatters["\\unexpanded\\def\\slx%s#1{{\\bf#1}}%%"] +local f_none_none = formatters["\\unexpanded\\def\\slx%s#1{{#1}}%%"] local f_texstyled = formatters["\\slx%s{%s}"] local f_hanging = formatters["\\slxb{%s}%s\\slxe"] @@ -90,7 +90,7 @@ local replacer = lpeg.replacer { ["\\"] = "\\slxB ", ["%"] = "\\slxP ", ["~"] = "\\slxT ", - [" "] = "\\slxS ", + [" "] = "\\slxS ", -- can be made more efficient: \\slxF{n} } local colors = nil @@ -169,6 +169,10 @@ end local p1 = lpeg.tsplitat(lpeg.patterns.newline) local p2 = lpeg.P("\\slxS ")^1 +local p3 = lpeg.Cs((lpeg.Cp() * lpeg.P(" ") * lpeg.Cp() / function(b,e) return "\\slxF{" .. (e-b-1) .. "}" end + + (1-lpeg.P(" "))^1)^0) + +-- slxb could have a \hskip so then we can replace the slxS's local function indent(str) local l = lpegmatch(p1,str) @@ -181,7 +185,10 @@ local function indent(str) else n = 0 end - l[i] = f_hanging(n,s) +s = lpegmatch(p3,s) -- can be combined + l[i] = f_hanging(n,s) -- "\\slxb{%s}%s\\slxe " +-- print(">",s) +-- print("<",l[i]) end end return concat(l,"\n") @@ -211,10 +218,12 @@ end \unprotect +\newdimen\scitespaceskip + \unexpanded\def\buff_scite_slxb#1% {%\begingroup - \hangindent\dimexpr\numexpr#1+1\relax\emwidth\relax - \hangafter \numexpr\numexpr#1+1\relax} + \hangindent\numexpr#1+2\relax\scitespaceskip + \hangafter 1\relax} \unexpanded\def\buff_scite_slxe {\par @@ -223,7 +232,9 @@ end \unexpanded\def\installscitecommands {\ctxlua{buffers.scite.installcommands()}% \let\installscitecommands\relax - \def\slxS{\fixedspace\allowbreak}% + \scitespaceskip\fontcharwd\font`0\relax + \unexpanded\def\slxS{\hskip\scitespaceskip}% + \unexpanded\def\slxF##1{\hskip##1\scitespaceskip\relax}% \let\slxb\buff_scite_slxb \let\slxe\buff_scite_slxe} @@ -251,7 +262,7 @@ end \raggedright \startcontextcode \startlines - \getbuffer[lex]% + \getbuffer[lex] \stoplines \stopcontextcode \stop} diff --git a/tex/context/modules/mkiv/s-languages-frequencies.lua b/tex/context/modules/mkiv/s-languages-frequencies.lua index 16213a412..4ff5cfe03 100644 --- a/tex/context/modules/mkiv/s-languages-frequencies.lua +++ b/tex/context/modules/mkiv/s-languages-frequencies.lua @@ -31,3 +31,7 @@ function moduledata.languages.frequencies.showlist(specification) end context.stoptabulate() end + +-- function MP.frqc(language,slot) +-- mp.print(languages.frequencies.getdata(language).frequencies[slot]) +-- end diff --git a/tex/context/modules/mkiv/x-setups-basics.mkiv b/tex/context/modules/mkiv/x-setups-basics.mkiv index 81c4e7cd2..24307e5c5 100644 --- a/tex/context/modules/mkiv/x-setups-basics.mkiv +++ b/tex/context/modules/mkiv/x-setups-basics.mkiv @@ -25,6 +25,8 @@ %D Currently we load the \XML\ file and when not in the english interface we just %D remap the relevant words to their translation. +%D Todo: use lua instead of synonyms + \unprotect \defineregister @@ -120,10 +122,55 @@ } \stopxmlsetups +\startxmlsetups xml:setups:assemblename:instance + \doifelse {\xmlatt{#1}{type}} {environment} { + \doifsomethingelse {\xmlatt{#1}{begin}} { + \edef\currentSETUPprefix{\xmllastatt}% + } { + \let\currentSETUPprefix\e!start + } + } { + \let\currentSETUPprefix\empty + } +% \edef\currentSETUPname{\xmlatt{#1}{name}} + \let\currentSETUPgenerated\empty + \doifelsenothing {\xmlatt{#1}{variant}} { + \let\currentSETUPvariant\empty + } { + \def\currentSETUPvariant{:\xmllastatt} + } + \edef\currentSETUPfullname { + \currentSETUPprefix + \currentSETUPname + \currentSETUPvariant + \currentSETUPgenerated + } +\stopxmlsetups + +% \startxmlsetups xml:setups:register +% \doifelse {\xmlatt{#1}{variant}} {instance} { +% \def\docommand##1% +% {\def\currentSETUPname{##1}% +% \xmlsetup{#1}{xml:setups:assemblename:instance} +% \expanded{\texcommand[stp:x:\currentSETUPfullname]{{#1}{##1}}}}% +% \processcommacommand[\clf_getinstances{#1}]\docommand +% } { +% \xmlsetup{#1}{xml:setups:assemblename} +% % not really needed if we just use setups +% \expanded{\texcommand[stp:x:\currentSETUPfullname]{{#1}{}}} +% } +% \stopxmlsetups + \startxmlsetups xml:setups:register + \doif {\xmlatt{#1}{variant}} {instance} { + \def\docommand##1% + {\xmlsetup{#1}{xml:setups:assemblename:instance} + \expanded{\texcommand[stp:x:\currentSETUPfullname:##1]{{#1}{##1}}}}% + \processcommacommand[\clf_getinstances{#1}]\docommand + } \xmlsetup{#1}{xml:setups:assemblename} % not really needed if we just use setups - \expanded{\texcommand[stp:x:\currentSETUPfullname]{#1}} + \expanded{\texcommand[stp:x:\currentSETUPfullname]{{#1}{}}} \stopxmlsetups \startluacode @@ -151,7 +198,6 @@ for c in xml.collected(x,"cd:interface/cd:define") do definitions[c.at.name] = c end - for c in xml.collected(x,"cd:interface/cd:interface") do c.at.file = c.__f__ c.at["xmlns:cd"] = nil @@ -225,6 +271,23 @@ context(n) end + local function getinstances(id) + local t = { } + local x = lxml.getid(id) + local r = xml.first(x,"/instances/resolve") + if r then + local x = setups.definitions[r.at.name] + for c in xml.collected(x,"constant") do + t[#t+1] = c.at.value + end + else + for c in xml.collected(x,"/instances/constant") do + t[#t+1] = c.at.value + end + end + return t + end + interfaces.implement { name = "getsetupstring", actions = function(s) @@ -248,6 +311,12 @@ arguments = "string", } + interfaces.implement { + name = "getinstances", + actions = { getinstances, function(t) context("%,t",t) end }, + overload = true, + arguments = { "string" }, + } \stopluacode % @@ -307,7 +376,12 @@ \unexpanded\def\showsetup {\c_cmd_kind\plustwo \cmd_show_setup} \unexpanded\def\showsetupinlist#1#2#3% - {\c_cmd_kind\plustwo\xmlsetup{#3}{xml:setups:typeset}\par} + {%(#1)(#2)(#3)\par + \edef\m_cmd_instance{\secondoftwoarguments#3}% + \c_cmd_kind\plustwo + \xmlsetup{\firstoftwoarguments#3}{xml:setups:typeset} + \let\m_cmd_instance\empty + \par} \installtextracker {cmd.showsetup} @@ -331,7 +405,12 @@ \fi \startelement[setup][name=#1]% \startelement[noexport][comment={setup definition #1}]% - \xmlsetup{\rawsynonymname{texcommand}{stp:x:#1}}{xml:setups:typeset} + \edef\cmd_id{\rawsynonymname{texcommand}{stp:x:#1}}% + \ifx\cmd_id\empty + missing: stp:x:#1 + \else + \xmlsetup{\expandafter\firstoftwoarguments\cmd_id}{xml:setups:typeset} + \fi \stopelement \stopelement} @@ -363,7 +442,11 @@ \stopxmlsetups \startxmlsetups xml:setups:make:instance - \m_cmd_instance + \ifx\m_cmd_instance\empty + \setupintfont{\xmlatt{#1}{value}} + \else + \m_cmd_instance + \fi \stopxmlsetups \startxmlsetups xml:setups:make:variable @@ -491,13 +574,15 @@ \stopxmlsetups \startxmlsetups xml:setups:typeset:instances - \xmldoif{#1}{/instances} { - \godown[.75\lineheight] - {\ttbf instances:} - \enspace - \xmlfilter{#1}{/instances/(constant|resolve)/command(xml:setups:instance)} - \removeunwantedspaces - } + \ifx\m_cmd_instance\empty + \xmldoif{#1}{/instances} { + \godown[.75\lineheight] + {\ttbf instances:} + \enspace + \xmlfilter{#1}{/instances/(constant|resolve)/command(xml:setups:instance)} + \removeunwantedspaces + } + \fi \stopxmlsetups \startxmlsetups xml:setups:typeset:yes diff --git a/tex/context/modules/mkiv/x-setups-proofing.mkiv b/tex/context/modules/mkiv/x-setups-proofing.mkiv index e40ee2ad1..5583b8861 100644 --- a/tex/context/modules/mkiv/x-setups-proofing.mkiv +++ b/tex/context/modules/mkiv/x-setups-proofing.mkiv @@ -17,9 +17,6 @@ \unprotect -\loadsetups - [\jobname.xml] - \setupbodyfont [10pt] @@ -45,6 +42,8 @@ \loadsetups[i-common-definitions] + \loadsetups[\jobname.xml] + \placeeverysetup \stoptext diff --git a/tex/context/test/mkiv/pdf-a2a.mkiv b/tex/context/test/mkiv/pdf-a2a.mkiv new file mode 100644 index 000000000..eea567f34 --- /dev/null +++ b/tex/context/test/mkiv/pdf-a2a.mkiv @@ -0,0 +1,40 @@ +% PDF/A-2a + +\enabletrackers[structure.tags,backend.tags] + +\setupbackend + [format=PDF/A-2a, + intent=sRGB IEC61966-2.1, % use entry here; otherwise problems with predefined default profile + profile=sRGB.icc, % use here + level=0] + +\setuptagging[state=start] + +\setupcolors[cmyk=no] +\definecolor[rgbblack][b=0.01] +\definecolor[transtest][r=1,g=1,t=.5] + +\placebookmarks[chapter][all][force=yes] + +\starttext + +\starttextcolor[rgbblack] + +\startchapter[title=aa,bookmark=bb,list=cc,marking=dd] + +Test it + +\stopchapter + +\stoptextcolor + +\hbox\bgroup + \blackrule[width=1cm,height=1cm,color=red] + \blackrule[width=1cm,height=1cm,color=green] + \blackrule[width=1cm,height=1cm,color=blue] + \blackrule[width=1cm,height=1cm,color=rgbblack] + \blackrule[width=1cm,height=1cm,color=transtest]\hskip-.5cm + \blackrule[width=1cm,height=1cm,color=transtest] +\egroup + +\stoptext diff --git a/tex/context/test/mkiv/pdf-a3a.mkiv b/tex/context/test/mkiv/pdf-a3a.mkiv new file mode 100644 index 000000000..e7bba6fd8 --- /dev/null +++ b/tex/context/test/mkiv/pdf-a3a.mkiv @@ -0,0 +1,43 @@ +% PDF/A-3a + +\nopdfcompression + + +\enabletrackers[structure.tags,backend.tags] + +\setupbackend + [format=PDF/A-3a, + intent=sRGB IEC61966-2.1, % use entry here; otherwise problems with predefined default profile + profile=sRGB.icc, % use here + level=0] + +\setuptagging[state=start] + +\setupcolors[cmyk=no] +\definecolor[rgbblack][b=0.01] +\definecolor[transtest][r=1,g=1,t=.5] + +\placebookmarks[chapter][all][force=yes] + +\starttext + +\starttextcolor[rgbblack] + +\startchapter[title=aa,bookmark=bb,list=cc,marking=dd] + +Test it + +\stopchapter + +\stoptextcolor + +\hbox\bgroup + \blackrule[width=1cm,height=1cm,color=red] + \blackrule[width=1cm,height=1cm,color=green] + \blackrule[width=1cm,height=1cm,color=blue] + \blackrule[width=1cm,height=1cm,color=rgbblack] + \blackrule[width=1cm,height=1cm,color=transtest]\hskip-.5cm + \blackrule[width=1cm,height=1cm,color=transtest] +\egroup + +\stoptext diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 907e4e19a..a0b906d0a 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 : 10/14/16 17:19:03 +-- merge date : 10/19/16 22:51:32 do -- begin closure to overcome local limits and interference @@ -4166,7 +4166,7 @@ if not modules then modules={} end modules ['util-fil']={ } local byte=string.byte local char=string.char -local extract=bit32.extract +local extract=bit32 and bit32.extract local floor=math.floor utilities=utilities or {} local files={} @@ -4328,16 +4328,18 @@ function files.readfixed4(f) return n+(0x100*c+d)/0xFFFF end end -function files.read2dot14(f) - local a,b=byte(f:read(2),1,2) - local n=0x100*a+b - local m=extract(n,0,30) - if n>0x7FFF then - n=extract(n,30,2) - return m/0x4000-4 - else - n=extract(n,30,2) - return n+m/0x4000 +if extract then + function files.read2dot14(f) + local a,b=byte(f:read(2),1,2) + local n=0x100*a+b + local m=extract(n,0,30) + if n>0x7FFF then + n=extract(n,30,2) + return m/0x4000-4 + else + n=extract(n,30,2) + return n+m/0x4000 + end end end function files.skipshort(f,n) -- cgit v1.2.3